对于对象公有的属性,会造成内存的浪费解决:公有的属性或者公有的方法放在原型对象上 function Person(name, age) { this.name = name; this.age = age; }Person.prototype.eat = "水果"var p = new Person("li", 19)var zhang = new Person("zhang", 20)console.log(p)console.log(zhang)