你真的已经搞懂JavaScript了吗?
2013-05-10 12:59
232 查看
在Baranovskiy博客中看到一篇So, you think you know JavaScript?的博客,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?
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); //理解两点:1、预编译期完成了函数声明和变量声明;2、预编译期函数声明会覆盖变量声明,但执行期变量赋值,而函数没有执行。
function a(x) { return x * 2; } var a; alert(a); //这个我觉得跟上面那题一样,预编译期函数声明会覆盖变量声明
function b(x, y, a) { arguments[2] = 10; alert(a); } b(1, 2, 3); //这个需要理解arguments对象
function a() { alert(this); } a.call(null); //这个比较简单了,平常经常用到,相当于a.call(window)
相关文章推荐
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?---转
- 你真的已经搞懂JavaScript了吗?
- 你真的已经搞懂JavaScript了吗?
- JavaScript检测浏览器cookie是否已经启动的方法
- 利用javascript判断浏览器是否已经安装ActiveX控件和是否禁止运行ActiveX控件
- Javascript-类-模块化[面向对象已经无处不在]
- javascript中几个不容易搞懂的知识点
- 三张图搞懂JavaScript的原型对象与原型链