原文: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")'
});
- function F(){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啟動時掃描病毒
- 在Linux中列印出"bug就在上面的選項中"
提交 提交並將結果作為留言