1. ["1", "2", "3"].map (parseint) how much?
For:[1,nan,nan]
Array.map (function (Currentvalue,index,arr), Thisvalue)
The elements in the original array return a new element after the method.
CurrentValue
The first argument of callback, the element that is currently passed in the array. Have to.
Index
The second argument of callback, the index of the element that is currently being passed in the array. Options available
Array
The third argument of callback, which calls an array of map methods. Options available
Thisvalue. The this value in the callback function defaults to the Window object
parseint (string, radix)
String: The character that needs to be converted, if not the string will be converted, ignoring whitespace.
Radix: integer type before the number 2-36. By default, 10 is used, which indicates decimal.
It is important to note that radix returns Nan if it is outside 2-36.
Because the parseint function receives 2 parameters, String,radix, if the map function returns these two parameters, regardless of whether the meaning is expected, it will be executed as a parameter.
In the case of 1-0-1,2,3, Map (parseint), parseint as the callback function will be: parseint (' 1 ', 0) (the previous number 1 is automatically converted to string 1), the other ibid.
Look at the following execution function results
parseint (' 1 ', 0);
parseint (' 2 ', 1);
parseint (' 3 ', 2);
So the result of the traversal is that the first element of the array can be displayed normally. The key value passed in is 1, the key name is 0 output 1
The second pass-through key value is 2, the key name is 1 output nan because 1 binary is unlikely to be greater than 1.
The third pass-in key value is 3, the key name is 2 output nan the same, the binary does not appear 3.
So get 1,nan,nan
2.var A = b = 10;
(function () {
var a = B = 20;
})();
Console.log (a);
Console.log (b);
Q: What is the output of a =? b =?
For:a=10, b=20
The problem of even waiting. So don't even wait for the random use.
When the assignment is equal, such as a = B = C;
This execution sequence is from right to left.
is quite with b = C;a = b;
Not b=c; A = C;
So go back to the topic.
At first it is var a = b = 10;
This time is b = 10;var a = b; So a = 10; Because the JS var declaration is not in strict mode, it is not necessary to write, because B does not exist, so it is automatically declared.
Then in an immediate execution function, var a = B = 20 is executed under this scope;
is equivalent to B =; var a = b; Because at this point B has been declared outside the global, so the change is the global variable.
There is var in front of a, so this a is only for variables under that scope. There is no modification to the global variable, a.
So print a = ten B = 20 outside the global.
JavaScript Classic Questions Summary