多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 即使对象初始化 ```javascript /* var obj = { name:"默认", age:"默认", showName:function(){ console.log("姓名:" + this.name); }, showAge:function(){ console.log("年龄:" + this.age); }, init:function(name,age){ this.name = name; this.age = age; } } obj.init("zs",18); console.log(obj.name); console.log(obj.age); */ // 优化 初始化只执行一次 ({ name:"默认", age:"默认", showName:function(){ console.log("姓名:" + this.name); }, showAge:function(){ console.log("年龄:" + this.age); }, init:function(name,age){ this.name = name; this.age = age; this.showName(); this.showAge(); } }).init("zs",18); ```