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