JavaScript学习--Item31 值得你挑战的JavaScript面试题(45题)

来源:互联网 发布:跑步计时器软件 编辑:程序博客网 时间:2024/05/19 20:00

你不知道的JavaScript系列,已经有这么多篇博文了,今天找了一些题目,我觉得,下面这些是你“不可能全部会做 ” 的javascript题目,不信你可以试试,答案在后面的博客给出,也许你是jser大神,欢迎挑战一下!

给答对一半以上的同学点10086个赞!!!!!!

1,以下表达式的运行结果是:

["1","2","3"].map(parseInt)A.["1","2","3"]B.[1,2,3]C.[0,1,2]D.其他 

2,以下表达式的运行结果是:

[typeof null, null instanceof Object]A.["object",false]B.[null,false]C.["object",true]D.其他

3,以下表达式的运行结果是:

[[3,2,1].reduce(Math.pow),[].reduce(Math.pow)]A.报错B.[9,0]C.[9,NaN]D.[9,undefined]

4,以下表达式的运行结果是:

var val = 'value';console.info('Value id '+(val === 'value')?'Something':'Nothing');A.SomethingB.NothingC.NaND.其他

5,以下表达式的运行结果是:

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

6,以下表达式的运行结果是:

var END = Math.pow(2,53);var START = END -100;var count = 0;for(var i = START ; i <= END ;i++){count ++;}console.log(count);A.0B.100C.101D.其他

7,以下表达式的运行结果是:

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]

8,以下表达式的运行结果是:

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.其他

9,以下表达式的运行结果是:

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

10,以下表达式的运行结果是:

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

11,以下表达式的运行结果是:

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]

12,以下表达式的运行结果是:

[parseInt(3,8),parseInt(3,2),parseInt(3,0)]A.[3,3,3]B.[3,3,NaN]C.[3,NaN,NaN]D.其他

13,以下表达式的运行结果是:

Array.isArray(Array.prototype)A.trueB.falseC.报错D.其他

14,以下表达式的运行结果是:

var a = [0];if([0]){    console.info(a == true);}else{    console.info("else");}A.trueB.falseC."else"D.其他 

15,以下表达式的运行结果是:

[]==[]A.trueB.falseC.报错D.其他

16,以下表达式的运行结果是:

[('5'+3),('5'-3)]A.["53",2]B.[8,2]C.报错D.其他

17,以下表达式的运行结果是:

1+-+++-+1A.trueB.falseC.报错D.其他 

18,以下表达式的运行结果是:

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.其他

19,以下表达式的运行结果是:

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.3B.12C.报错D.其他

20,以下表达式的运行结果是:

var a = 111111111111111110000;b = 1111;console.info(a+b);A.111111111111111111111B.111111111111111110000C.NaND.Infinity 

21,以下表达式的运行结果是:

ar x = [].reverse;x();A.[]B.undefinedC.报错D.window

22,以下表达式的运行结果是:

Number.MIN_VALUE>0A.trueB.falseC.报错D.其他

23,以下表达式的运行结果是:

[1<2<3,3<2<1]A.[true,true]B.[true,false]C.报错D.其他

24,以下表达式的运行结果是:

2 == [[[2]]]A.trueB.falseC.undefinedD.其他

25,以下表达式的运行结果是:

[3.toString(),3..toString(),3...toString()]A.["3",error,error]B.["3","3.0",error]C.[error,"3",error]D.其他

26,以下表达式的运行结果是:

(function(){var x1 =y1 =1;})();console.info(y1);console.info(x1);A.11B.errorerrorC.1errorD.其他

27,以下表达式的运行结果是:

var a = Function.length,    b = new Function().length;a === bA.trueB.falseC.errorD.other

28,以下表达式的运行结果是:

var a = Date(0);var b = new Date(0);var c = new Date();[a === b, b === c, a === c]A.[true, true, true]B.[false, false, false]C.[false, true, false]D.[true, false, false]

29,以下表达式的运行结果是:

var min = Math.min(), max = Math.max()min < maxA.trueB.falseC.errorD.other

30,以下表达式的运行结果是:

function captureOne(re, str) {  var match = re.exec(str);  return match && match[1];}var numRe  = /num=(\d+)/ig,    wordRe = /word=(\w+)/i,    a1 = captureOne(numRe,  "num=1"),    a2 = captureOne(wordRe, "word=1"),    a3 = captureOne(numRe,  "NUM=2"),    a4 = captureOne(wordRe,  "WORD=2");[a1 === a2, a3 === a4]A.[true, true]B.[false, false]C.[true, false]D.[false, true]

31,以下表达式的运行结果是:

var a = new Date("2014-03-19"),    b = new Date(2014, 03, 19);[a.getDay() === b.getDay(), a.getMonth() === b.getMonth()]A.[true, true]B.[true, false]C.[false, true]D.[false, false]

32,以下表达式的运行结果是:

if ('http://giftwrapped.com/picture.jpg'.match('.gif')) {  'a gif file'} else {  'not a gif file'}A.'a gif file'B.'not a gif file'C.errorD.other

33,以下表达式的运行结果是:

function foo(a) {    var a;    return a;}function bar(a) {    var a = 'bye';    return a;}[foo('hello'), bar('hello')]A.["hello", "hello"]B.["hello", "bye"]C.["bye", "bye"]D.other

34,以下表达式的运行结果是:

var a = {class: "Animal", name: 'Fido'};a.classA."Animal"B.ObjectC.an errorD.other

35,以下表达式的运行结果是:

var a = new Date("epoch")A.Thu Jan 01 1970 01:00:00 GMT+0100 (CET)B.current timeC.errorD.other

36,以下表达式的运行结果是:

var a = /123/,    b = /123/;a == ba === bA.true, trueB.true, falseC.false, falseD.other

37,以下表达式的运行结果是:

What is the result of this expression? (or multiple ones)var a = [1, 2, 3],    b = [1, 2, 3],    c = [1, 2, 4]a ==  ba === ba >   ca <   cA.false, false, false, trueB.false, false, false, falseC.true, true, false, trueD.other

38,以下表达式的运行结果是:

var a = {}, b = Object.prototype;[a.prototype === b, Object.getPrototypeOf(a) === b]A.[false, true]B.[true, true]C.[false, false]D.other

39,以下表达式的运行结果是:

function f() {}var a = f.prototype, b = Object.getPrototypeOf(f);a === bA.trueB.falseC.nullD.other

40,以下表达式的运行结果是:

function foo() { }var oldName = foo.name;foo.name = "bar";[oldName, foo.name]A.errorB.["", ""]C.["foo", "foo"]D.["foo", "bar"]

41,以下表达式的运行结果是:

"1 2 3".replace(/\d/g, parseInt)A."1 2 3"B."0 1 2"C."NaN 2 3"D."1 NaN 3"

42,以下表达式的运行结果是:

function f() {}var parent = Object.getPrototypeOf(f);f.name // ?parent.name // ?typeof eval(f.name) // ?typeof eval(parent.name) //  ?A."f", "Empty", "function", "function"B."f", undefined, "function", errorC."f", "Empty", "function", errorD.other

43,以下表达式的运行结果是:

var lowerCaseOnly =  /^[a-z]+$/;[lowerCaseOnly.test(null), lowerCaseOnly.test()]A.[true, false]B.errorC.[true, true]D.[false, true]

44,以下表达式的运行结果是:

var lowerCaseOnly =  /^[a-z]+$/;[lowerCaseOnly.test(null), lowerCaseOnly.test()]A.[true, false]B.errorC.[true, true]D.[false, true]

45,以下表达式的运行结果是:

[,,,].join(", ")A.", , , "B."undefined, undefined, undefined, undefined"C.", , "D.""
0 0
原创粉丝点击