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

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>

from: http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname

posted @ 2015-07-03 14:33  Waichung  阅读(302)  评论(0编辑  收藏  举报