这是第一种:
var myObject={
value:0,
increment:function(inc){ this.value += typeof inc === "number"?inc:1;
}
};这是第二种,感觉不一样,但是又不知道该如何说清楚。
var myObject = function () { var value = 0; return {
increment: function (inc) {
value += typeof inc === "number" ? inc : 1;
},
getValue: function () { return value;
}
}
}();
BIG阳
呼如林
随时随地看视频慕课网APP
相关分类