(1)典型的函数声明
function slide(arguments){
//...code/
}
(2)以函数表达式的形式定义函数
var slide = function(arguments){
//...code
}
他们有所区别:例子二是赋值给了一个变量
var slide=new Object(){
//...code
}
个人理解 构造函数是为了多个调用 配合this
例子:
var b=a("我");
console.log(b);
function a(name){
var student=new Object();
student.name=name;
student.sayHi=function(){
console.log(this.name+"说大家好");
}
return student;
}
JS函数表达的几种写法
原文:http://www.cnblogs.com/hello-web/p/6663742.html