转载来自:http://blog.csdn.net/gufeng672/article/details/9961221
常见写法:
function Test(){alert("test");
}
调用:Test()
匿名函数:
var test=function(){
alert("test");
}
调用:test();
写法3:
(function () {
alert('test');
})();
写法4:
var Test = {
test1:function(){
alert('test1');
}
,test2:function(){
alert('test2');
}
}
使用:var t = Test.test1();
写法5:
var Test = function(){};
Test.prototype={
test1:function(){
alert('test1');
}
,test2:function(){
alert('test2');
}
}
使用:var t = new Test();
t.test2();