• Native JS prepared Snake games


    This example shares the specific code of JS Snake game for your reference. The specific contents are as follows Just finished JS imitating the tutorial and put the JS native applet you wrote. HTML part <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <meta http-equiv=”X-UA-Compatible” content=”IE=edge”> <meta name=”viewport” content=”width=device-width, initial-scale=1.0″> <title>Document</title> <link rel=”stylesheet” href=”./css/index.css” > </head> […]

  • JS uses the reduce () method to process tree structured data


    catalogue definition grammar example 1. The initial value init is not passed 2. When transmitting the initial value 3. Array de duplication 4. Use reduce to group and merge the object objects in the array 5. Use reduce to process the menu structure returned from the menu back end definition The reduce () method executes […]

  • HTML & CSS & JS compatibility tree (ie, Firefox, chrome)


    What is a tree in web design? To put it simply, clicking a link will expand the subordinate directory, and then clicking Join will be the simplest tree. How to implement it? It is also very simple. There is an attribute display in CSS, which can control the reality of the content or not. Then […]

  • Calling JS functions in iframe pages with JS


    Recently, I made a paper opening report every day. I was itching to design the web again. I suddenly encountered a problem. In the past, I used to run in ie when designing web pages. I never considered Firefox, let alone chrome, but now it is different. At least I think web pages incompatible with […]

  • Two ways to implement new in JavaScript


    preface What happens when you new a constructor? “Well known” three steps: Create an empty object, assign its reference to this, and inherit the prototype of the function; Add properties and methods to this object through this; Finally, return the new object pointed to by this, that is, the instance. Generally speaking, in JS, it […]

  • How to use webworker in JS


    catalogue 1、 Webworker’s initial experience 2、 Common APIs for webworker 1、postMessage(data) 2、terminate() 3、message 4、error 3、 Worker context 4、 About worker 1、 Webworker’s initial experience Therefore, JavaScript is single threaded and has a background. As follows: <!DOCTYPE html> <head> <title>singleThread</title> <meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″/> </head> <body> <script> //Add to the task queue. After the execution of […]

  • Explain the native method of operating cookies, cookie store


    catalogue 1. How to operate cookies at ordinary times 2. New way: cookiestore 2.1 basic methods 2.2 setting cookies 2.3 obtaining cookies 2.4 get all cookies 2.5 deleting cookies 2.6 monitoring cookie changes 3. Summary 1. How to operate cookies at ordinary times Document.cookie can obtain all cookie strings of the current domain. Each cookie […]

  • How does JavaScript use promise to control the number of concurrent requests


    1、 Scene Suppose there is such a scenario: there are 30 asynchronous requests to be sent, but for some reasons, we must control the number of concurrent requests at the same time within 5, and get the response results as quickly as possible. As shown in the figure: The queuing in the above figure is […]

  • How to implement the custom adapter of Axios


    catalogue 1. Functions to be realized by the adapter 1.1 promise and tools 1.2 format of response 1.3 timeout setting 1.4 active cancellation request 2. Write a custom adapter 3. Add the adapter to Axios 4. Summary 1. Functions to be realized by the adapter When we implement additional data modules based on Axios, we […]

  • How does JS make your mobile interaction experience better


    catalogue 1. Immediate feedback 1.1 instant feedback of buttons 1.2 continuous feedback 1.3 page initialization 1.4 data display 2. Behavior following 2.1 click the button to call the pop-up window 2.2 when there are object changes in the list 2.3 sliding following of wire slide 3. Consider the holding posture of the mobile device 3.1 […]

  • JS takes you into the world of proxy


    catalogue 1. Basic structure of proxy 2. Proxy and reflect 3. Proxy array 4. Proxy function 5. Some simple application scenarios 5.1 count the context and times of function calls 5.2 realize an anti shake function 5.3 implement observer mode 6. Comparison between proxy and object.defineproperty 6.1 advantages and disadvantages of object.defineproperty 6.2 advantages and […]

  • Explain in detail all kinds of cyclic speed measurement you don’t know in JS


    catalogue preface 1. For loop 2. While loop and do while loop 3. Foreach, map and reduce loops 3.1 brief introduction to foreach 3.2 velocity measurement of foreach, etc 4. for-of 4.1 brief introduction to for of 4.2 cyclic velocity measurement of for 5. For in cycle 6. Summary preface Before testing the cycle speed, […]