function sideffecting (ary) { ary[0] = ary[2];} function Bar (a,b,c) { sideffecting (arguments); return A + B + C;} Bar (1,1,1)
16, this is a big pit, especially when it comes to ES6 grammar. Knowledge Points:
First of allThe arguments object is an Array-like object corresponding to the arguments passed to a function.
In other words arguments
object
, C is arguments[2], so the modification of C is the modification of arguments[2] . So the answer is 21
.
However!!!!!!
when a function parameter any rest parameters, any default parameters or any destructured parameters
is involved, the arguments is not one mapped arguments object
. Changes to C will not be reflected on the arguments, arguments is the function of the parameters.
function sideffecting (ary) { ary[0] = ary[2];} function bar (a,b,c=3) { ten; sideffecting (arguments); return A + B + C;} Bar (1,1,1)//
Let the reader understand:
[123321]
17, the problem can also be examined by the operator of the law of calculation.
This problem will make people think that is 2 > 1 && 2 < 3
actually not. This problem is equivalent to
1 2 true true3 = 13true32 falsefalse 1 0 1 true;
So the answer is: [True,true]
3 . toString () 3 .. ToString ()3... tostring ()
18, the problem is also very funny, I did the right, the answer is:error, ‘3‘, error
Because in JS 1.1
, it 1.
is a .1
valid number. So when it comes to parsing, 3.toString
.
does this really belong to this number or function call? It can only be a number, because it's 3.
legal. We put it on the browser to see the color.
(function () { var1;}) (); Console.log (y); Console.log (x) ;
19, the problem is relatively simple: Y is assigned to the global, X is a local variable. So the answer is: 1 and error x is not defined
var a =/123/, =/123/== = = = B
20, the regular is the object, so even if the regular literal amount of the same, they are not equal. Answerfalse, false
var a = {}, b == = = B, object.getprototypeof (a) = = = B]
21, Knowledge points:
Only Function has a prototype property, so it a.prototype
is undefined
.
and Object.getPrototypeOf(obj)
returns a prototype of a specific object (the object's internal [[prototype]]
value). Answerfalse, true
function f () {} var a = F.prototype, b == = = B
F.prototype is the object that would become the parent of any objects created with new F while object.getprototypeof return s the parent in the inheritance hierarchy.
F.prototype is a prototype of an F instance created using new, while Object.getprototypeof is the prototype of the F function . Please see:
A = = object.getprototypeof (new// true// true )
function foo () {} var oldname ="bar"; [ Oldname, Foo.name]
22, Knowledge points:
[‘foo‘, ‘foo‘]。
the answer is because the name of the function is immutable .
[,,,].join ("")
23、知识点:[,,,] => [undefined × 3]
Because JavaScript allows the last element to be followed when the array is defined ,
, this is a sparse array of length three (which is three in length and not 0, 1, 23 Properties, OH). Answer:", , "
var min = math.min (), max => Max
24, Knowledge points:
Interestingly, Math.min does not pass arguments back Infinity
, and Math.max does not pass arguments back -Infinity
. Answer:true
var a = function.length, new= = b
25. We know that the property of a length
function instance is the number of parameters for the signature of the functions, so b.length = = 0. Another function.length is defined as 1. So not equal, the answerfalse
var a = Date (0); var New Date (0); var New = = = b, b = = = c, a = = c]
26, about the question of date, it should be noted that
(1) If the parameter is not passed is equivalent to the current time.
(2) If it is a function call, returns a string.
Answerfalse, false, false
function foo (a) { var A; return A;} function Bar (a) { var'bye'; return A;} [Foo ('hello'), bar ('hello')]
27, in two functions, a as a parameter is actually declared, so the var a; var a = ‘bye‘
answer is actually a; a =‘bye‘。
so ["Hello", "Bye"]
JS tamping Foundation: Javascript Perverted analysis (bottom)