So, you think you know JavaScript? (你认为你懂JS吗)

原文是在这里的: http://dmitry.baranovskiy.com/post/91403200

 

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 @ 2010-01-26 15:46  玉米疯收  阅读(2112)  评论(1编辑  收藏  举报