1, the following expression runs as a result:["1", "2", "3"].map (parseint)a.["1", "2", "3"]b.[1,2,3]c.[0,1,2]d. Other ============== Answer: D,parseint The second parameter range is: 2-32, if passed in 0, the default is handled by 10. Please view the parseint function definition yourself
2, the following expression runs as a result:[typeof null, NULL instanceof Object]A.["Object", false]b.[null,false]c.["Object", True]d. Other
================ answer: A, about instanceof in-depth explanation please refer to: http://www.ibm.com/developerworks/cn/web/1306_jiangjj_jsinstanceof/
3, the following expression runs as a result:[ [3,2,1].reduce (Math.pow), [].reduce (MATH.POW)]A. Error B. [9,0] C.[9,nan]d.[9,undefined]
=================== Answer: A, an empty array with reduce will be an error because reduce will use the first element of the array to do initvalue when there is no incoming initvalue, but the empty array does not have the first element4, the following expression runs as a result:var val = "value";Console.info ("Value id" + (val = = = "Value")? " Something ":" Nothing ");A.somethingb.nothingc.nand. Other
=========== Answer: The comparison of A,js is divided into two types, value type comparison and reference type comparison. Value types only Compare values equal5, the following expression runs as a result:var name = "World";(function () {if (typeof name = = = "undefined") {var name = "Jack";console.info ("Goodbye" + name);}else{console.info ("Hello" + name);}})();A.goodbye Jackb.hello jackc.goodbye Undefinedd.hello undefined
============= Answer: A,JS Variables Act on only the global and function levels, and then Var declares that the variable will have a hoisting process6, the following expression runs as a result:var START = END-100;var count = 0;For (var i = START; I <= END; i++) {count + +;}Console.info (count);a.0b.100c.101d. Other ================ Answer: D, error, end undefined
7, the following expression runs as a result:var arr = [0,1,2];arr[10] = ten;Arr.filter (function (x) {return x = = = undefined});a.[undefined x 7]b.[0,1,2,10]c.[]d.[undefined]
============= Answer: C,filter does not handle undefined elements in the array8, the following expression runs as a result:var = 0.2;var one = 0.1;var eight = 0.8;var six = 0.6;[Two-one = = One,eight-six = =];A.[true,true]b.[false,false]c.[true,false]d. Other
========== Answer: C, do not know why. What are the differences between the 0.1 and 0.2 floating point numbers? Ask for answers9, the following expression runs as a result:function ShowCase (value) {switch (value) {Case "A":console.info ("Case A");Break ;Case "B":console.info ("Case B");Break ;Case undefined:console.info ("undefined");Break ;Default:Console.info ("Do not know!");}}showCase (New String ("A"));A.case AB. Case BC. Do not knowd.undefined
============= Answer: c,switch use = = = to compare10, the following expression runs as a result:function ShowCase (value) {switch (value) {Case "A":console.info ("Case A");Break ;Case "B":console.info ("Case B");Break ;Case undefined:console.info ("undefined");Break ;Default:Console.info ("Do not know!");}}showCase (String ("A"));A.case AB. Case BC. Do not knowd.undefined
============= and repetition of the above questions11, the following expression runs as a result:function isodd (num) {return num% 2 = = 1;}function IsEven (num) {return num% 2 = = 0;}function Issane (num) {return IsEven (num) | | IsOdd (num);}var values = [7,4, "+", -9,infinity];Values.map (issane);A.[true,true,true, True,true]b.[true,true,true,true,false]c.[true,true,true,false,false]d.[true,true,false, False,false]
=================== answer: C, negative to find surplus is negative12, the following expression runs as a result:[parseint (3,8), parseint (3,2), parseint (3,0)]A.[3,3,3]b.[3,3,nan]c.[3,nan,nan]d. Other
============ answer: D,[3, NaN, 3], refer to the first question13, the following expression runs as a result:Array.isarray (Array.prototype)A.trueb.falsec. Error d. Other
================== Answer: A
14, the following expression runs as a result:var a = [0];if ([0]) {Console.info (A = = true);}else{Console.info ("Else");}A.trueb.falsec. " Else "D. Other ============== answer: B, the array is a reference type, using = = to compare whether it is the same object
15, the following expression runs as a result:[]==[]A.trueb.falsec. Error d. Other
============ Answer: B, refer to the previous question
16, the following expression runs as a result:[("5" +3), ("5"-3)]A.["", 2]b.[8,2]c. Error d. Other
============== Answer: A, no need to explain
17, the following expression runs as a result:1+-+++-+1A.trueb.falsec. Error d. Other ============== answer: C, perverted question18, the following expression runs as a result:var arr = Array (3);arr[0] = 2Arr.map (function (elem) {return "1";});a.[2,1,1]b.["1", "1", "1"]c.[2, "1", "1"]d. Other
=============== Answer: D,map does not handle elements of undefined. The result should be: ["1", undefined,undefined]19, the following expression runs as a result:function sideffecting (arr) {arr[0] = arr[2];}function Bar (a,b,c) {C = Ten;sideffecting (arguments);return a+b+c;}Bar (1,1,1);a.3b.12c. Error d. Other
============= Answer: 21, I want to go
20, the following expression runs as a result:var a = 111111111111111110000;b = 1111;Console.info (a+b);A.111111111111111111111b.111111111111111110000c.nand.infinity
=================== Answer: B, do not know the specific reason, guess the integer out of bounds?21, the following expression runs as a result:ar x = [].reverse;x ();A.[]b.undefinedc. Error D.window
================= Answer: C, you can use the browser to try to know why22, the following expression runs as a result:number.min_value>0A.trueb.falsec. Error d. Other
================= Answer: A23, the following expression runs as a result:[1<2<3,3<2<1]A.[true,true]b.[true,false]c. Error d. Other
=============== answer: A, examine the comparison of the combination of the characters and the true and the integral type24, the following expression runs as a result:2 = = [[[2]]]A.trueb.falsec.undefinedd. Other
=================== answer: A, [[[2]]].tostring () is ' 2 ', which is equivalent to the constant invocation of the array's join method, 2== "2" needless to say.25, the following expression runs as a result:[3.toString (), 3..toString (), 3...toString ()]a.["3", error,error]b.["3", "3.0", Error]c.[error, "3", error]d. Other
=============== Answer: C, calling a method on the number type requires writing two points, because you write a point that will be parsed into a float26, the following expression runs as a result:(function () {var x1 =y1 =1;})();console.info (y1);Console.info (x1);A.1,1b.error,errorc.1,errord. Other
==================== Answer: c,y1 equivalent to the definition on the window27, enumerate the problems of IE and FF script compatibility28, what's wrong with the following function? How to improve? function initbuttons () {var BODY = document.body,button,i;for (i =0;i<5;i++) {button = document.createelement ("button button.innerhtml = "button" + I;button.addeventlistener ("click", Function (e) {alert (i); 2015,false); Body.appendchild (button);}} Initbuttons ();
================ closure problem, note that closures hold variables, not variable values, so the alert is 4 when executed.29. Write a piece of code that determines the most frequently occurring characters in a string and counts the number of occurrences. var str= "Aswerwsdfsfs", result={' ch ': ', ' num ': -1},str.split (""). ForEach (function (c,k) {!! RESULT[C]? result[c]++: (Result[c] = 1);(Result[c] > Result[num]) && (result[ch] = c);})
Console.log (Result)
===============================30, what is the difference between the two pieces of code? SetTimeout (function () {/* code block */settimeout (arguments.callee,10);},10); SetInterval (function () {/* code block */},10); Super-Practical JavaScript code snippet
30 JavaScript topics that you "can't do all"