易于维护的写法

 1 function Klass() {

 2     this.id = new Date().getTime();

 3     this.name = '';

 4 }

 5 

 6 Klass.prototype.get = function() {

 7     return this.id;

 8 };

 9 

10 Klass.prototype.set = function(name) {

11     this.name = name;

12 };

13 

14 var test1 = new Klass();

15 var test2 = new Klass();

16 test1.set('tttt');

17 test2.set('qqqq');

 

你可能感兴趣的:(写)