前端學習:教程&開發模塊化/規範化/工程化/優化&工具/調試&值得關注的博客/Git&面試-前端資源彙總前端
歡迎提issues斧正:30題_題目git
以前在學習時把問題和答案分開了,這兒也分開吧。這樣在看得時候無心識的會多思考一下。茶餘飯後,來杯咖啡github
["1","2","3"].map(parseInt) A.["1","2","3"] B.[1,2,3] C.[0,1,2] D.其餘
[typeof null, null instanceof Object] A.["object",false] B.[null,false] C.["object",true] D.其餘
[[3,2,1].reduce(Math.pow),[].reduce(Math.pow)] A.報錯 B.[9,0] C.[9,NaN] D.[9,undefined]
var val = 'value'; console.info('Value id '+(val === 'value')?'Something':'Nothing'); A.Something B.Nothing C.NaN D.其餘
var name = 'World'; (function(){ if(typeof name === 'undefined'){ var name = "Jack"; console.info('Goodbye '+ name); }else{ console.info('Hello ' + name); } })(); A.Goodbye Jack B.Hello Jack C.Goodbye undefined D.Hello undefined
var START = END -100; var count = 0; for(var i = START ; i <= END ;i++){ count ++; } console.info(count); A.0 B.100 C.101 D.其餘
var arr = [0,1,2]; arr[10] = 10; arr.filter(function(x){return x === undefined}); A.[undefined x 7] B.[0,1,2,10] C.[] D.[undefined]
var two = 0.2; var one = 0.1; var eight = 0.8; var six = 0.6; [two -one == one,eight- six == two]; A.[true,true] B.[false,false] C.[true,false] D.其餘
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 A B.Case B C.Do not know D.undefined
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 A B.Case B C.Do not know D.undefined
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,'13',-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]
[parseInt(3,8),parseInt(3,2),parseInt(3,0)] A.[3,3,3] B.[3,3,NaN] C.[3,NaN,NaN] D.其餘
Array.isArray(Array.prototype) A.true B.false C.報錯 D.其餘
var a = [0]; if([0]){ console.info(a == true); }else{ console.info("false"); } A.true B.false C."else" D.其餘
[]==[] A.true B.false C.報錯 D.其餘
[('5'+3),('5'-3)] A.["53",2] B.[8,2] C.報錯 D.其餘
1+-+++-+1 A.true B.false C.報錯 D.其餘
var arr = Array(3); arr[0] = 2 arr.map(function(elem){return '1';}); A.[2,1,1] B.["1","1","1"] C.[2,"1","1"] D.其餘
function sidEffecting(arr){ arr[0] = arr[2]; } function bar(a,b,c){ c = 10; sidEffecting(arguments); return a+b+c; } bar(1,1,1); A.3 B.12 C.報錯 D.其餘
var a = 111111111111111110000; b = 1111; console.info(a+b); A.111111111111111111111 B.111111111111111110000 C.NaN D.Infinity
var x = [].reverse; x(); A.[] B.undefined C.報錯 D.window
Number.MIN_VALUE>0 A.true B.false C.報錯 D.其餘
[1<2<3,3<2<1] A.[true,true] B.[true,false] C.報錯 D.其餘
2 == [[[2]]] A.true B.false C.undefined D.其餘
[3.toString(),3..toString(),3...toString()] A.["3",error,error] B.["3","3.0",error] C.[error,"3",error] D.其餘
(function(){ var x1 =y1 =1; })(); console.info(y1); console.info(x1); A.1,1 B.error,error C.1,error D.其餘
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); },false); body.appendChild(button); } } initButtons();
判斷一個字符串中出現次數最多的字符,並統計出現的次數。面試
(1)setTimeout(function(){ /*代碼塊*/ setTimeout(arguments.callee,10); },10); (2)setInterval(function(){ /*代碼塊*/ },10);
聲明:本文源於學習的時候保存的一份word文檔。word複製自一篇博客「JavaScript30個你不可能全會的題目」,具體出處已無。不過,最原始源自書籍《超實用的JavaScript代碼段》app