0
HTML代碼:DOM onLoad事件沒有jQuery的
<html>
<head>
</head>
<body>
<script type="text/javascript" src="/js/colorbook.js"></script>
<script type="text/javascript">
book.init();
</script>
</body>
</html>
JS代碼:
var book = (function(){
init = function(){
console.log ("initialized")
}return init();
}());
問題:上面的代碼工作。但我無法理解如何?任何JS的人可以幫我在這裏或指導我如何開始調試這個代碼來理解它。
嗯,你究竟爲什麼困惑了,js是如何執行的或爲什麼這個特定的函數語義有效? – Nomad101 2013-05-13 04:35:17
@ Nomad101:如果你能幫我解決這兩個問題,那將會很棒。 – buildingagent 2013-05-13 04:43:05
是JS代碼位於您引用的JS文件中的唯一代碼嗎? – Nomad101 2013-05-13 04:55:01