
//构造函数functionCat(name,color){this.namename;this.colorcolor;this.runfunction(){console.log(${this.name}can run)}}//原型属性和方法Cat.prototype.type猫科动物;Cat.prototype.eatfunction(){console.log(${this.name}--${this.color}--${this.type}--吃老鼠);};//生成实例。var cat1newCat(大毛,黄色);var cat2newCat(二毛,黑色);console.log(cat1.type);// 猫科动物cat1.eat();// 吃老鼠cat2.eat();//吃老鼠console.log(cat1.eatcat2.eat);//turecat1.run()cat2.run()console.log(cat1.runcat2.run);//false