选出以下代码的执行结果
1
["1", "2", "3"].map(parseInt)
A.["1", "2", "3"]
B.[1, 2, 3]
C.[0, 1, 2]
D.other
2
[typeof null, null instanceof Object]
A.["object", false]
B.[null, false]
C.["object", true]
D.other
3
[ [3,2,1].reduce(Math.pow), [].reduce(Math.pow) ]
A.an error
B.[9, 0]
C.[9, NaN]
D.[9, undefined]
4
var val = 'smtg';
console.log('Value is ' + (val === 'smtg') ? 'Something' : 'Nothing');
A.Value is Something
B.Value is Nothing
C.NaN
D.other
5
var name = 'World!';
(function () {
if (typeof name === 'undefined') {
var name = 'Jack';
console.log('Goodbye ' + name);
} else {
console.log('Hello ' + name);
}
})();
A.Goodbye Jack
B.Hello Jack
C.Hello undefined
D.Hello World
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.0
B.100
C.101
D.other
7
var ary = [0,1,2];
ary[10] = 10;
ary.filter(function(x) { return x === undefined;});
A.[undefined × 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.other
9
function showCase(value) {
switch(value) {
case 'A':
console.log('Case A');
break;
case 'B':
console.log('Case B');
break;
case undefined:
console.log('undefined');
break;
default:
console.log('Do not know!');
}
}
showCase(new String('A'));
A.Case A
B.Case B
C.Do not know!
D.undefined
10
function showCase2(value) {
switch(value) {
case 'A':
console.log('Case A');
break;
case 'B':
console.log('Case B');
break;
case undefined:
console.log('undefined');
break;
default:
console.log('Do not know!');
}
}
showCase2(String('A'));
A.Case A
B.Case B
C.Do not know!
D.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.other
13
Array.isArray( Array.prototype )
A.true
B.false
C.error
D.other
14
var a = [0];
if ([0]) {
console.log(a == true);
} else {
console.log("wut");
}
A.true
B.false
C."wut"
D.other
15
[]==[]
A.true
B.false
C.error
D.other
16
'5' + 3
'5' - 3
A."53", 2
B.8, 2
C.error
D.other
17
1 + - + + + - + 1
A.2
B.1
C.error
D.other
18
var ary = Array(3);
ary[0]=2
ary.map(function(elem) { return '1'; });
A.[2, 1, 1]
B.["1", "1", "1"]
C.[2, "1", "1"]
D.other
19
function sidEffecting(ary) {
ary[0] = ary[2];
}
function bar(a,b,c) {
c = 10
sidEffecting(arguments);
return a + b + c;
}
bar(1,1,1)
A.3
B.12
C.error
D.other
20
var a = 111111111111111110000,
b = 1111;
a + b;
A.111111111111111111111
B.111111111111111110000
C.NaN
D.Infinity
21
var x = [].reverse;
x();
A.[]
B.undefined
C.error
D.window
22
Number.MIN_VALUE > 0
A.false
B.true
C.error
D.other
23
[1 < 2 < 3, 3 < 2 < 1]
A.[true, true]
B.[true, false]
C.error
D.other
24
// the most classic wtf
2 == [[[2]]]
A.true
B.false
C.undefined
D.other
25
3.toString()
3..toString()
3...toString()
A."3", error, error
B."3", "3.0", error
C.error, "3", error
D.other
26
(function(){
var x = y = 1;
})();
console.log(y);
console.log(x);
A.1, 1
B.error, error
C.1, error
D.other
27
var a = /123/,
b = /123/;
a == b
a === b
A.true, true
B.true, false
C.false, false
D.other
28
var a = [1, 2, 3],
b = [1, 2, 3],
c = [1, 2, 4]
a == b
a === b
a > c
a < c
A.false, false, false, true
B.false, false, false, false
C.true, true, false, true
D.other
29
var a = {}, b = Object.prototype;
[a.prototype === b, Object.getPrototypeOf(a) === b]
A.[false, true]
B.[true, true]
C.[false, false]
D.other
30
function f() {}
var a = f.prototype, b = Object.getPrototypeOf(f);
a === b
A.true
B.false
C.null
D.other
31
function foo() { }
var oldName = foo.name;
foo.name = "bar";
[oldName, foo.name]
A.error
B.["", ""]
C.["foo", "foo"]
D.["foo", "bar"]
32
"1 2 3".replace(/\d/g, parseInt)
A."1 2 3"
B."0 1 2"
C."NaN 2 3"
D."1 NaN 3"
33
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", error
C."f", "Empty", "function", error
D.other
34
var lowerCaseOnly = /^[a-z]+$/;
[lowerCaseOnly.test(null), lowerCaseOnly.test()]
A.[true, false]
B.error
C.[true, true]
D.[false, true]
35
[,,,].join(", ")
A.", , , "
B."undefined, undefined, undefined, undefined"
C.", , "
D.""
36
var a = {class: "Animal", name: 'Fido'};
a.class
A."Animal"
B.Object
C.an error
D.other
37
var a = new Date("epoch")
A.Thu Jan 01 1970 01:00:00 GMT+0100 (CET)
B.current time
C.error
D.other
38
var a = Function.length,
b = new Function().length
a === b
A.true
B.false
C.error
D.other
39
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]
40
var min = Math.min(), max = Math.max()
min < max
A.true
B.false
C.error
D.other
41
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]
42
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]
43
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.error
D.other
44
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
答案: DAADA DCCCA CDABB AADDB DBAAC CCAAB CDCCC DDBBB CDAB