First, data types

Data type: basic: undefined, null, string, number, Boolean, symbol(ES6) A. Typeof typeof null return type error, return object reference type, The others all returns object a. toString toString () method was the prototype of the object Returns the format [object] Xxx method of use: object. The prototype. ToString. Call (1) copy depth: Parse (json.stringify (obj))/Shallow copy + recursionCopy the code

Second, scope

The nesting of scope-chain functions creates the hierarchical closure principle for scopes: scope-chainCopy the code

Prototype and inheritance

{} b. new Object() c. object.create ({}) JS implement a class: constructor method syntax sugar class(ES6) prototype chain: Any class (function) that has a constructor Object has at least two properties (constructor, proto) that point to the function itself. The prototypeobject function has a prototype property that points to the parent class. The prototypeobject function has a prototype property that points to the parent class. The prototypeobject function can access the prototype object directly (because the instance has a prototype object that proTO points to the constructor). Example Inheritance: Points the prototype of the child object to an instance of the parent object. Prototype inheritance: points the prototype of the child object to the prototype extends(ES6)Copy the code

4. New and this

The new operator steps: first, it creates an instance object ({} this refers to the object and inherits the constructor's prototype). Second, attributes and methods are added to the object referenced by this and the newly created object is referenced by this. Finally, it implicitly returns this. This always points to the direct caller of the function and if you have the new keyword, this points to the instance object that comes out of the new and in the event, this points to the object that triggered the event and in the Case of attachEvent in IE this always points to the global object inside the Window arrow function, Is the object in scope when defined, not the object in scope when usedCopy the code

B. apply, call, and bind

Change this to refer to bind inside the function body to return the corresponding function. Apply and call immediately call bind and call pass in the parameter list apply pass in the arrayCopy the code

Vi. Data processing

Create a temporary array, iterate over the current array, and then determine if there is a temporary array. Push to the temporary array, and return b. Array subscript: Create a temporary array, iterate over the current array, and then determine if the index is the first occurrence of c. Push D. new Set() e. Push D. new Set() e. Push D. Filter () : Use indexOf to determine the first index in the current Array == The current index value Array sort: Recursive sum: count the number of repetitions of items in the Array:Copy the code

Seven, the Event Loop

SetTimeout, setInterval, setImmediate, I/O, UI Rendering Microtasks: Process.nextTick (Node only), Promise, MutationObserver tasks of different types will enter the corresponding Event Queue. Events in macro tasks are placed in the callback queue, which triggers thread maintenance; The event loop is maintained by the JS engine thread:Copy the code

Eight, browser page rendering process

Procedure: a. The browser parses the HTML source code and then executes a DOM tree. The browser parses the CSS code, computes the final style data, and creates a CSSOM tree, which is the rendering tree and is similar to the DOM tree, but different from the RENDERING tree. Draw the render book onto the pageCopy the code

9. Browser cache

A. Before loading a resource, the browser checks whether the resource matches the strong cache based on some HTTP headers. If the strong cache matches, the browser directly reads the resource from its cache without sending a request to the server. For example, if the cache configuration of a CSS file hits the strong cache when the browser loads the page, the browser loads the CSS directly from the cache without sending the request to the server where the page is located. When the strong cache does not hit, the browser must send a request to the server. The server verifies that the resource hit the negotiation cache against some other HTTP headers. If the negotiation cache hits, the server returns the request, but does not return the data for the resource. Instead, the client is told to load the resource directly from the cache, and the browser will load the resource from its own cache. Strong caching and negotiated caching have one thing in common: if a hit is made, the resource is loaded from the client cache, not from the server. The difference is that the strong cache does not send requests to the server, whereas the negotiated cache sends requests to the server. When the negotiated cache also fails to hit, the browser loads the resource data from the server directly: Expires or cache-control negotiated cache: last-Modified, if-modified-since, ETag, or if-none-matchCopy the code