1. What's the result of: // string
Typeof (null)
====================== Q1 answer ==========================
Typeof is an operator. A string result is returned to indicate the type of the operand. Typeof (null) returns "object", so the result of typeof "object" is string
2. Are the algorithms of the following checks completely equvalent? // Yes
Typeof Foo = 'undefined'
And
Typeof Foo = 'undefined'
=========== Q2 answer ====================================
Whether = OR =, typeof returns the string "Boolean"
3. What's the result of: // 1
100 ['string'] ['length']
============= Q3 answer ====================================
We know that there are boxing and unboxing concepts in Java, and this concept also exists in Js. Therefore, the above 100 ['string'] ['length'] is equivalent to new number (100) ['string'] ['length']. So here it means to calculate the number of parameters of the tostring method in the number example. We also know that the tostring method of the number type can be used to input a number and return an N-base number. For example, 100. tostring (2) means to return the binary data format of 100. Therefore, the tostring method has a formal parameter. Therefore, the Length attribute of the tostring function is 1.
4. What's the result of: // 8
VaR A = (1, 5-1) * 2
====================== Q4 answer ========================
The Group operation is performed in parentheses, and the result of the last group is 5-1, multiplied by 2, or 8.
5. What's the result of: // 20, 20, 10, 10
VaR x = 10;
VaR Foo = {
X: 20,
Bar: function () {var x = 30; return this. X ;}
};
Console. Log (
Foo. Bar (),
(FOO. bar )(),
(FOO. bar = Foo. bar )(),
(FOO. Bar, foo. bar )()
);
=================================== Q5 answer ======================
It's really hard to explain this. Let's look at the specifications by yourself .....
6. What's the result of: // undefined, undefined
Function f (x, y ){
X = 10;
Console. Log (arguments [0], arguments [1]);
}
F ();
=============== Q6 answer ====================
When no parameter is input, arguments is not associated with the X and Y parameters. So no matter how you modify X, the length of arguments is always 0, so arguments [0] and arguments [1] are all undefined
7. What's the result of: // 20
VaR B = 10, c = (20, function (x) {return x+ 100}, function () {return arguments [0]});
A = B + C
({X: 10}). x
=============== Q7 answer ====================
Note that do not be confused by line breaks. Here we are actually calculating the value in the expression A = B + C ({X: 10}). X. C is the function () {return arguments [0]}. Therefore, this expression is equivalent:
A = 10 + {X: 10}. X. So the result is 20.
8. What's the result of: // undefined
1. Z
=============== Q8 answer ====================
First, refer to the boxing and unboxing concepts in Q3, which is equivalent to new number (1.). Z.
The number prototype does not have the Z attribute, so it is undefined. Here, why do we need to use two dots? It is because a dot is parsed into a decimal point. It is not parsed as an attribute operator.
9. What's the result of: // undefined, 30, 20
({X: 10, foo: function (){
Function bar (){
Console. Log (X );
Console. Log (y );
Console. Log (this. X );
}
With (this ){
VaR x = 20;
Var y = 30;
Bar. Call (this );
}
}
}). Foo ();
10. What's the result of: // referenceerror or possibly no error
Foreach (K in {A: 10, B: 20 }){//...}
================ Q10 answer ================
If foreach is a function and K is defined, there will be no error. Otherwise, an error is reported.
Referenceerror: K is not defined