原文:http://asenbozhilov.com/articles/quiz.html
这些题目都源自ECMA-262-3规范.Good luck!
译者注:作者是根据ES3出的题,但我没发现和ES5有不同表现的地方.暂时不给出答案解释.请到http://ecma-international.org/ecma-262/5.1/找答案
-
Function.prototype.toString.call({
name: 'F',
body: 'print("Javascript is hard")'
});- TypeError
- empty string
- [object Function]
-
new String({
toString : function (){ return this;},
valueOf : function () {return this;}
});- TypeError
- String value
- String object
- Object
-
typeof (new Date() + new Date());
- number
- object
- string
- undefined
-
typeof (void null);
- object
- null
- undefined
- SyntaxError
-
function F() {}
F.prototype = new Function;
Object.prototype.toString.call(new F());- [object Function]
- [object Array]
- [object String]
- [object Object]
-
[].length = -2;
- TypeError
- -2
- RangeError
- 0
-
var D = Math.pow(2, 33);
(D | D) == D;- true
- false
- RangeError
-
'_string_'.replace(/^/, "$'");
- _string_
- '_string_
- $'_string_
- _string__string_
-
eval('typeof F; function F() {}');- undefined
- object
- string
- function
-
debugger;
- 给微软寄钱
- 可能会SyntaxError
- 把你的源代码通过电子邮件发送给Brendan Eich
- ReferenceError
- 在Windows启动时扫描病毒