var name = function() {} & function name() {}
The difference is that
functionOne
is defined at run-time, whereas functionTwo
is defined at parse-time for a script block. For example:<script>
// Error
functionOne();
var functionOne = function() {
}
</script>
<script>
// No error
functionTwo();
function functionTwo() {
}
</script>
沒有留言 :
張貼留言