class Bar {
constructor(){
this.name = 'bar-name'
this.age = 18
}
info() {
return `name is ${this.name}, age is ${this.age}`
}
}
const b = new bar
b.name // bar-name
b.info() // "name is bar-name, age is 18"
Bar.prototype.info() // "name is bar-name, age is 18"
b.constructor.name // Bar
b2 = {...b}
b2.name // 'bar-name'
b2.info() //error
b2.constructor // Object