07 2012 档案

摘要:原文链接:http://www.codeproject.com/Articles/182416/A-Collection-of-JavaScript-GotchasIntroductionThis article is an introduction to the weird side of JavaScript, and it definitely has a weird side! Software developers who usually write code in another language will find a lot of intriguing "featur 阅读全文
posted @ 2012-07-28 22:48 家有小河马 阅读(173) 评论(0) 推荐(0)
摘要:原文出处:http://davidshariff.com/blog/what-is-the-execution-context-in-javascript/In this post I will take an in-depth look at one of the most fundamental parts of JavaScript, theExecution Context. By the end of this post, you should have a clearer understanding about what the interpreter is trying to d 阅读全文
posted @ 2012-07-26 14:32 家有小河马 阅读(351) 评论(0) 推荐(0)
摘要:varf=function(){ return1;}console.log(f());//1functionf(){ return2;}console.log(f());//1这是为什么呢?runtime的时候,var会重新内建,function在编译时内建。相当于vara=2;vara=1;console.log(a);function定义的会被先建立。var的在运行的时候建立。所以每次执行的时候,var的把之前建立的给覆盖掉了。或者可以这样描述function的相当于静态的var的是动态的var在执行的时候建立 阅读全文
posted @ 2012-07-26 13:22 家有小河马 阅读(168) 评论(0) 推荐(0)
摘要:vara=0;varb=3;functioncom(){ a=1; returnfunction(){ b=a+a; }} com();console.log(a); //1console.log(b); //3------------------------------vara=0;varb=0;functioncom(){ a=1; c=5; returnfunction(c){ b=a+c; }} com()();console.log(a); //1console.log(b); //NaNconsole.log(c); //5 阅读全文
posted @ 2012-07-26 10:15 家有小河马 阅读(138) 评论(0) 推荐(0)
摘要:ss=Object.beget(hi);ss=hi;-------------------------hi = {a:1};ss=Object.beget(hi);alert(ss.a);//1ss.a = 2;alert(ss.a);//2alert(hi.a);//1delete ss.aalert(ss.a);//1这个就是所谓的原型了 阅读全文
posted @ 2012-07-18 17:08 家有小河马 阅读(145) 评论(0) 推荐(0)
摘要:今天群里的大大们强势吐槽:字面量就是用最直观的方式创建一个对象其实是很常见的东西,以数组为例:var arr = [1,2,3]就是字面量形式,var arr = new Array(1,2,3)就是对象形式JS里面貌似 BooleanLiteral NumberLiteral StringLiteral NullLiteral 属于LiteralObjectLiteral 和ArrayLiteral 貌似不算Literal按照es5的描述,还有regexp literalsliteral就是前面提到的“字面量”,也见过翻译成“直接量”“字面值”的es5里的这些arrayliteral和obj 阅读全文
posted @ 2012-07-18 17:06 家有小河马 阅读(1356) 评论(0) 推荐(1)