虚度人生

导航

you think you know javascript

zaka在twitter发的回答Baranovskiy的So, you think you know JavaScript?,引起广泛的关注。
那5道题目我猜测在国内确实能倒下一大片搞js开发的,一直以来感觉牛人不少,但也有为数不少的程序员缺乏脚踏实地的精神,缺乏钻研的精神,希望能让一部分人有所警醒。
摘抄原文如下:
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);

这次的问题不附答案,大家不要急着去搜,应该自己先想想。结果,然后运行代码对比结果,再自己想想为什么,想不明白再去网上。

posted on 2010-01-31 17:30  nozer0  阅读(294)  评论(3编辑  收藏  举报