码迷,mamicode.com
首页 > 其他好文 > 详细

Function Expression

时间:2015-05-12 22:52:40      阅读:171      评论:0      收藏:0      [点我收藏+]

标签:

  One of the key characteristics of function declarations is function declaration hoisting, whereby function declarations are read before the code excutes. That means a function declaration may appear after code that calls it and still work:

1 sayHi();
2 function sayHi(){
3     alert("Hi!");
4 }

  Function expressions act like other expressions and, therefore, must be assigned before usage. The following causes an error:

1 sayHi();              // error - function doesn‘t exist yet
2 var sayHi = function(){
3     alert("Hi!");
4 };

  It‘s advisable to always use arguments.callee of the function name whenever you‘re writing recursive functions.

Function Expression

标签:

原文地址:http://www.cnblogs.com/linxd/p/4498763.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!