1. Js prevents time bubbling by default:

1) Event.stopPropagation () prevent event bubblings (), prevent time from spreading to document, but default event preventDefault()return false; Prevents both event bubbling and default eventsCopy the code

2. Logic code, you can print it out and see oh, the answer is in the comments

Var a = [1, 2]; Var b = a.c oncat ([3, 4, [5, 6]]). 1. What is the length of array B?Copy the code

var data = [];
for(var i = 0; i<3; i++){ data[i] =function(){ console.log(i); }} 2, data[0] =? data[1] = ? data[2] = ?Copy the code

var z = 10;
function foo(){
    console.log(z);
}
(function(funArg){ var z = 20; funArg(); })(foo) console.log(z); / / 3, z =?Copy the code

function fact (num){ 
    if(num<=1){ 
	return1}else{
	returnnum*arguments.callee(num-1) } } var anotherFact = fact; fact =null console.log(anotherFact(4)); / / 4, (anotherFact (4)?Copy the code

3. There is a place I don’t understand: arguments.callee

  • Firstly, what are arguments?
  • Arguments is an array-like but non-array object created during a function call, and stores the arguments actually passed to the function, not just the list of arguments declared by the function.
  1. Arguments. callee is a function that points to the arguments object and gets the body of the current function, representing the function in which it is run. This is typically used in anonymous functions.
  2. Arguments. callee is a recursive algorithm that implements computing factorial functions, however

    4, The difference between call and Apply:

    • Each function contains non-inherited methods: call() and apply()
    • Definition:
      • Apply: Calls a method on an object that replaces the current object with another.

      • Call: Calls a method on an object that replaces the current object with another.

    • Similarities:
      • The function is called in a specific scope, which is equivalent to setting the value of this in the function body to extend the scope of the function.
    • The difference between:
      • Apply () : Can take at most two arguments: the this object from which the function runs and the array of arguments.
        • If argArray is not a valid array or arguments object, then a TypeError will result. If neither argArray nor thisObj is supplied, then the Global object will be used as thisObj.

    Apply ([thisObj [,argArray]]);Copy the code

      • Call () : The first argument is the same as the apply() method, but the arguments passed to the function must be enumerated.
        • The Call method can be used to call a method instead of another object. The Call method can change the object context of a function from its original context to the new object specified by thisObj. If no thisObj argument is provided, the Global object is used for thisObj.

    Syntax: call([thisObject[,arg1 [,arg2 [,...,argn]]]]);Copy the code

    5. Browser event stream:



    1. The event bubbling
      1. Events are initially received by the most specific element (the node with the deepest nesting level in the document) and then propagated up the hierarchy to the less specific nodes

    2. Event capture
      1. The idea of event capture is that less specific nodes should receive events earlier, while the most specific nodes should receive events last. The intent of event capture is to catch an event before it reaches its intended destination

    3. The DOM event flow
      1. Between the capture phase and the event bubble phase

    6. Improve web page performance

    • Reduce HTTP requests:
      • Image loading will also produce HTTP requests, so it is recommended to minimize the use of network images, if there are many images, use font ICONS
    • Using CDN address:
      • A CDN (Content Delivery network) is a set of Web servers distributed in multiple geographic locations to deliver content to users more efficiently. When optimizing performance, the selection of servers to deliver content to specific users is based on measurement of online MOOCs congestion.
      • CDN can also back up data, expand storage capacity, and cache data. CDN also helps ease Web traffic peak pressure.
    • Put the style sheet in the header
      • Reduce the time for the first screen to gradually display the page content, improve user experience, and prevent the “white screen”. Being able to display content as quickly as possible and provide visual feedback is important for users with slow Internet connections
    • Place the script at the bottom
      • As with style sheets, placing them at the bottom reduces the time the first screen appears. The download and execution of JS blocks the building of the Dom tree (or, more precisely, interrupts the updating of the Dom tree), so the script tag placed in an HTML section within the first screen will truncate the content of the first screen
    • Avoid CSS expressions
      • CSS expressions are a powerful and dangerous way to dynamically set CSS properties, supported by IE5 and later, before IE8.
    • Use external JavaScript and CSS
      • Inline scripts or styles can reduce HTTP requests and, in theory, speed up page loading. In practice, however, when scripts or styles are imported from outside the file, it is possible for the browser to cache them so that they can be used directly for later loading, while the SIZE of the HTML document is reduced to speed up loading.

    7.HTTPS vs. HTTP:

    • Definition:
      • HTTPS: the secure HTTP channel, which is simply the secure version of HTTP. The security of HTTPS is based on SSL, so the details of encryption need SSL.
      • HTTP: Hypertext Transfer protocol (HTTP) is a data transfer protocol that specifies the rules for communication between the browser and the World Wide Web server, and transmits World Wide Web documents over the Internet.
    • The difference between:
      • HTTPS: HTTPS requires you to apply for a certificate from a CA. Generally, a free certificate is rare and requires a fee. HTTPS is a secure SSL encrypted transport protocol.
      • HTTP: HTTP is a hypertext transfer protocol. Information is transmitted in plaintext.