function Cat(name){ this.name = name; } Cat.prototype.say = function(){ return "hello," + this.name; }; var cat1 = new Cat("cat1"); console.log(cat1.say()); //hello,cat1 var cat2 = new Cat("cat2"); console.log(cat2.say()); //hello,cat2 console.log(cat1.say === cat2.say); //true
Sign in to make a reply
未来有妮和我