Saturday, 1 February 2014

var functionName = function() {} vs function functionName() {}

he 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>

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More