在构造函数中
公有 在一般在原型对象上
私有属性 通过this关键字去添加的
hasOwnProperty可以判断属性是私有的还是共有的
function Person(name,age){this.name = name;this.age = age;}/*在构造函数中公有 在一般在原型对象上私有属性 通过this关键字去添加的hasOwnProperty可以判断属性是私有的还是共有的*/Person.prototype = {constructor:Person,sayName:function(){console.log(this.name)},sayAge(){console.log(this.age)}}var p = new Person("cheng",20);console.log(p.hasOwnProperty("name"))console.log(p.hasOwnProperty("sayName"))
