您的位置:首页 > Web前端 > JavaScript

【转】So, you think you know JavaScript?

2010-06-09 17:22 316 查看
http://dmitry.baranovskiy.com/

Quick test for real understanding of JavaScript core beyond closures and scopes. Here five small scripts. Try to answer what will be alerted in each case without running them in the console. Then you could create a test file and easily check your answers. Ready?

if (!("a" in window)) {
var a = 1;
}
alert(a);
var a = 1,
b = function a(x) {
x && a(--x);
};
alert(a);
function a(x) {
return x * 2;
}
var a;
alert(a);
function b(x, y, a) {
arguments[2] = 10;
alert(a);
}
b(1, 2, 3);
function a() {
alert(this);
}
a.call(null);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: