摘要:
1 function writeCode(callback){2 callback();3 }4 5 function introduceBugs(){6 alert("introduceBugs");7 }8 9 writeCode(introduceBugs);注意introduceBugs()作为参数传入writeCode()时,函数后面是不带括号的。括号的意思是执行函数,而这里我们希望传入一个引用,让writeCode()在合适的时机执行它(调用它)。 阅读全文
posted @ 2013-05-08 16:59
小猩猩君
阅读(169)
评论(0)
推荐(0)
摘要:
1 // 反模式,仅用于演示 2 3 // 全局函数 4 function foo() { 5 alert('global foo'); 6 } 7 function bar() { 8 alert('global bar'); 9 }10 11 function hoistMe() {12 13 console.log(typeof foo); // "function"14 console.log(typeof bar); // "undefined"15 16 foo(); // "local foo&qu 阅读全文
posted @ 2013-05-08 10:06
小猩猩君
阅读(954)
评论(0)
推荐(0)

浙公网安备 33010602011771号