let p = {
name: "zf",
age: 23
}
let { name, age } = p
console.log(name)
console.log(age)
let myname, myage
({ name: myname, age: myage } = p)
console.log(myname)
console.log(myage)
function createPerson(name, age, job) {
let o = new Object();
o.name = name
o.age = age
o.job = job
o.sayName = () => {
console.log(this.name)
};
return o
}
let p1 = createPerson('zf', 23, 'student')
let p2 = createPerson('zff', 43, 'police')
function Person(name, age, job) {
this.name = name
this.age = age
this.job = job
//没有显式创建对象
//属性和方法直接复制给this
//没有返回值
}
let pp1 = new Person('zf', 32, 'teacher')
let pp2 = new Person('zff', 52, 'cleaner')
console.log(pp1.constructor == Person)
console.log(pp1.__proto__)
console