您的位置:首页 > Web前端 > JavaScript

Js写法

2015-10-30 11:16 567 查看
常见写法:
function Test(){
alert("test");
}
调用:Test()

写法2:

匿名函数:

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(); 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  javascript