function Animal(name) {
this.name = name ;
}
Animal.prototype = {
sayName: function() {
alert(this.name) ;
},
sayHi: function() {
alert("Hi!") ;
}
} ;
var dog = new Animal("dog"),
cat = new Animal("cat") ;
dog.sayName() ;
cat.sayName() ;
dog.sayHi() ;
cat.sayHi() ;