注意 var a=function(){}与
function a(){}的区别
- //
- /* if(!("a" in global)){
- var a=1;
- }
- console.log(a); */
- /* var b=1;//添加的一行,加深理解
- var a=1,b=function a(x){
- x&&a(--x);
- };
- console.log(a);
- console.log(b); */
- //var w=1,w=2;
- //console.log(w);
- /*
- //这样定义的函数是在本文件包含进就定义了,所以不管var a;
- 放前面后面,如果不是未定义都会覆盖掉,这里由于是未定义所以未覆盖
- function a(x){
- return x*2;
- }
- var a;
- console.log(a); */
- /* function b(x,y,a){
- arguments[2]=10;
- console.log(a);
- }
- b(1,2,3); */
- /* function a(){
- console.log(this);
- }
- a.call(null);//注意这里如果 a.call({});结果不一样 */
来源: https://www.oschina.net/code/snippet_1419328_58646