10

javascript之函数1

 3 years ago
source link: https://zwkang.com/?p=306
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

函数的三种基本创建方法有:
1、函数声明式
function functionName(arg){
//函数体
}
函数声明式重要特征是函数声明提升  这个的意思是在执行函数代码前会读取函数声明  所以函数声明可以放在调用语句后面
2、函数表达式
var functionName = function(arg0){
//函数体
}
这种创建方法是比较常见的用匿名函数创建并赋值给一个变量的方法
注意  函数表达式是没有提升的  意味着如果你函数表达式语句前调用函数是会错误的
3、var functionName=new Function('arg1','arg2','return arg1+arg2');
这种方法一般很少使用因为频繁Function()构造函数去创建函数效率太低了

Comments

发表评论 取消回复

电子邮件地址不会被公开。 必填项已用*标注

评论

姓名 *

电子邮件 *

站点

在此浏览器中保存我的名字、电邮和网站。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK