标签:http io ar java sp div on 问题 cti
JavaScript有很多地方和我们熟知的C、Java等的编程习惯不同,这些不同会产生很多让人意想不到的事情。前段时间在知乎有人发了写Javascrtip试题,觉得挺好玩的,这里跟大家分享一下。定州市科技工业局
01
1 |
( function () { |
2 |
return typeof arguments; |
3 |
})(); |
4 |
A. "object" |
5 |
B. "array" |
6 |
C. "arguments" |
7 |
D. "undefined" |
答案:A
02
1 |
var f = function g() { |
2 |
return 23; |
3 |
}; |
4 |
typeof g(); |
5 |
A. "number" |
6 |
B. "undefined" |
7 |
C. "function" |
8 |
D. Eorror |
答案:D
03
1 |
( function (x) { |
2 |
delete x; |
3 |
return x; |
4 |
})(1); |
5 |
A. 1 |
6 |
B. null |
7 |
C. undefined |
8 |
D. Error |
答案:A
04
1 |
var y = 1, |
2 |
x = y = typeof x; |
3 |
x; |
4 |
A. 1 |
5 |
B. "number" |
6 |
C. undefined |
7 |
D. "undefined" |
答案: D
05
1 |
( function f(f) { |
2 |
return typeof f(); |
3 |
})( function () { |
4 |
return 1; |
5 |
}); |
6 |
A. "number" |
7 |
B. "undefined" |
8 |
C. "function" |
9 |
D. Error |
答案:A
06
01 |
var foo = { |
02 |
bar: function () { |
03 |
return this.baz; |
04 |
}, |
05 |
baz: 1 |
06 |
}; |
07 |
( function () { |
08 |
return typeof arguments[0](); |
09 |
})(foo.bar); |
10 |
A. "undefined" |
11 |
B. "object" |
12 |
C. "number" |
13 |
D. "function" |
答案:A
07
01 |
var foo = { |
02 |
bar: function () { |
03 |
return this.baz; |
04 |
}, |
05 |
baz: 1 |
06 |
}; |
07 |
typeof (f = foo.bar)(); |
08 |
A. "undefined" |
09 |
B. "object" |
10 |
C. "number" |
11 |
D. "function" |
答案:A
08
01 |
var f = ( function f() { |
02 |
return "1" ; |
03 |
}, function g() { |
04 |
return 2; |
05 |
})(); |
06 |
typeof f; |
07 |
A. "string" |
08 |
B. "number" |
09 |
C. "function" |
10 |
D. "undefined" |
答案: B
09
1 |
var x = 1; |
2 |
if ( function f() {}) { |
3 |
x += typeof f; |
4 |
} |
5 |
x; |
6 |
A. 1 |
7 |
B. "1function" |
8 |
C. "1undefined" |
9 |
D. NaN |
答案: C
10
1 |
var x = [typeof x, typeof y][1]; |
2 |
typeof typeof x; |
3 |
A. "number" |
4 |
B. "string" |
5 |
C. "undefined" |
6 |
D. "object" |
答案: B
11
01 |
( function (foo) { |
02 |
return typeof foo.bar; |
03 |
})({ |
04 |
foo: { |
05 |
bar: 1 |
06 |
} |
07 |
}); |
08 |
A、“undefined” |
09 |
B、“object” |
10 |
C、“number” |
11 |
D、Error |
答案: A
12
01 |
( function f() { |
02 |
function f() { |
03 |
return 1; |
04 |
} |
05 |
return f(); |
06 |
function f() { |
07 |
return 2; |
08 |
} |
09 |
})(); |
10 |
A、1 |
11 |
B、2 |
12 |
C、Error (e.g. “Too much recursion”) |
13 |
D、undefined |
答案:B
13
1 |
function f() { |
2 |
return f; |
3 |
} |
4 |
new f() instanceof f; |
5 |
A、true |
6 |
B、false |
答案:B
14
1 |
with ( function (x, undefined){}) length; |
2 |
A、1 |
3 |
B、2 |
4 |
C、undefined |
5 |
D、Error |
答案:B
具体答案大家可以自己运行得出,为什么会得出这样的结果,我也有一些不懂的地方,怕误人子弟,所以这里就不解答这里的问题了。
标签:http io ar java sp div on 问题 cti
原文地址:http://www.cnblogs.com/xiaoyang002/p/4034870.html