码迷,mamicode.com
首页 > 编程语言 > 详细

So,you think you know JavaScript?

时间:2017-04-07 14:42:39      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:ons   turn   create   check   with   span   bsp   res   creat   

Quick test for real understanding of JavaScript core beyound 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);

 

以上为JavaScript大师Dmitry Baranovskiy 在09年给出的5个五个有趣的题目,看看你能不能都答对?

原文:http://dmitry.baranovskiy.com/post/91403200

 

本文作者starof,因知识本身在变化,作者也在不断学习成长,文章内容也不定时更新,为避免误导读者,方便追根溯源,请诸位转载注明出处:http://www.cnblogs.com/starof/p/6677948.html有问题欢迎与我讨论,共同进步。

 

So,you think you know JavaScript?

标签:ons   turn   create   check   with   span   bsp   res   creat   

原文地址:http://www.cnblogs.com/starof/p/6677948.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!