cati.setName("Tom"); cat2.setName("Angela"); cat2=cat1; cat2.setName("Doraemon"); System.out.println(cat1.getName()); System.out.println(cat2.getName());
function Cat(name) { this.name = name; } Cat.prototype.setName = function(newName) { this.name = newName; }; Cat.prototype.getName = function() { return this.name; }; var cat1 = new Cat('Tom'); var cat2 = cat1; cat2.setName('Doraemon'); console.log(cat1.getName()); console.log(cat2.getName());