One side

The interviewer was so nice that he didn’t even let me introduce myself. Just get your hands dirty and start writing questions for me to answer.
The first question (relatively easy is to test variable promotion and asynchronous)
var a = 10;
function A(){ console.log(a); Var a = 20; var a = 20; var a = 20; console.log(a); // The second output: 20 because the above variable is assigned to 20for(var a=1; a<5; a++){setTimeout(function(){ console.log(a); // The fourth time output 4 5 // answer: because the timer is asynchronous asynchronous code will be thrown on the task queue. Let the main thread code execute first. The execution timer will not be thrown to the main thread until the task queue is notified that it is ready to execute. So while the timer is executingfor},0)}} a (); console.log(a); / / the third output 10 = = = = = = = = = = = = = = = = = = = = = = = = = : I think I can improve the difficulty = = = = = = = = = = = = = = = = = = = = = / / the classmate of everyone guess the answer Order sequence must be the best output on the console, log (a); // Output what? var a ="10"; console.log(a); // Output whatfunctionA(a){ console.log(a); // Output what? var a ="20"; console.log(a); // Output what? arguments[0] ="40"; console.log(a); // Output what?for(var a=1; a<5; a++){setTimeout(function(){ console.log(new Date+a); // Output what? },1000) } console.log(new Date+a); // Output what? } A("30"); console.log(a); // Output what?Copy the code
Question 2 (this is too easy if you see the interesting front end of the question)
var obj = {
    showFunction:function(){}} obj. ShowFunction () //this points to who obj var newObj = obj. NewObj () // which window does this point to? // Which window does this point to? // Which window does this point to? In strict mode, this is not automatically converted to window. The default is undefined.Copy the code
A. this B. this C. this D. this
“This” usually refers to an object. So in general, direct calls to functions and variables are objects to which this refers.
  • 1: Calls to Windows are made globally directly or through window this
var a = 10; window.a; = = 10; this.a == 10; a == 10;Copy the code
  • 2: This in an object call refers to the object currently being called
var obj = {
    showFunction:function(){
        this == obj
    }
}
Copy the code
  • 3: This refers to the DOM element that binds the event
document.querySelector("#id").onclick =function(){
    this == document.querySelector("#id")}Copy the code
  • 4: Constructor this refers to the instantiated object
function Person(){
    this.name = "Mr. Song Wei"} var man = new Person();} var Person = new Person();Copy the code
  • 5: Call, apply, and bind refer to this in the function body
var obj = {
    names : "Mr. Song Wei"
}
var names ="Teacher Wanda";
function fun(){
    console.log(this.names);
}

fun.call(obj);      //"Mr. Song Wei"
fun.apply(obj);     //"Mr. Song Wei"
fun.bind(obj)();    //"Mr. Song Wei"
Copy the code

A little tidbit

What methods are available to call a function
function fun(){} // Direct function call 1: fun(); 2: new fun(); // New fun(); // Try var names ="Mr. Song Wei"
function fun(){ console.log(this.names) }; new fun(); // Output what? // The call method is actually a procedure that fun() implicitly calls fun.call(window). 3:fun.call(window); //bind4:fun.apply(window); //bindCalling a function that returns a function body needs to be called again to execute 5:fun.bind(window)();Copy the code
Question 4: What is a prototype chain
1: When a reference type inherits the properties and methods of another reference type, a stereotype connection will be generated. 2: I said that the stereotype chain is an association between the instantiation and the stereotype of the constructor. It is mainly used to ensure the order of access of variables.Copy the code
5. What is closure? (I am waiting for this question in the interview.
1: has access to a variable function in the scope of another function. (js advanced programming) 2: function body variables exist in function scope is a closure. (JS authoritative guide) 3: function closure. Closure is a dynamic environment in the running process of the function code, which is a runtime and dynamic concept. Closures are functions that can read the internal variables of other functions. Since in javascript, only subfunctions inside a function can read local variables, closures can be understood as "functions defined inside a function." An internal function + a variable of an external function forms a closure. 6: Functions that have access to another scope are closures. Closures are a general term for function + execution environment.Copy the code
Question 6. What is scope
In a nutshell. Is the scope of accessibility of functions and variables. Scopes are divided into global scope function scope andevalScope.Copy the code
7 CSS box model explain…
The box model: Box-sizing: border-box; margin-width: 0.0px; margin-border: 0.0px; margin-width: 0.0px; margin-border: 0.0px; margin-border: 0.0px; margin-border: 0.0px Box-sizing :border-boxCopy the code

Vue question (you can go to see my summary of vue interview question, I will not explain the first one, I will continue later when I have time)

  • 1: The underlying implementation of the virtual DOM
  • 2: Bidirectional data binding
  • 3: Life cycle of vUE

Second interview (there is time to continue later)

conclusion

Those of you who have seen these questions, if you know how to do it, and those of you in Beijing can go to this company and try it. Give you a little confidence. The interview thing is that the interview manager will ask you if you likeThere are some moons in the sky. Look at you is to ask you how many stars in the sky. So calm down and go through a few interviews. Ok, the first time to write so many words of the article, some time for a long time. Need to go out for a big workout and relax. Zha follow up.