Javascript 原型编程初探

创建两个对象独立运行

 var PlayTrace = function (interVal,name) {
this.interVal = interVal;
this.playName = name;
}; PlayTrace.prototype = function () {
startPlay = function (beginVal) {
if (this.playInterVal) {
clearInterval(this.playInterVal);
}
this.playInterVal = window.setInterval(function (name) {
console.log(name + "," + beginVal);
beginVal++;
}, this.interVal, this.playName); } return {
startPlay: startPlay
}
}(); var play1 = new PlayTrace(1000, "play1");
play1.startPlay(1); var play2 = new PlayTrace(2000,"play2");
play2.startPlay(100);
上一篇:异步IO/数据库/队列/缓存


下一篇:oracle误删的表恢复