const object = {
name: 'Andrew',
getName() {
return this.name
}
}
class ObjectClass {
constructor(name) {
this.name = name
}
getName() {
return this.name
}
}
const object2 = new ObjectClass('Andrew')
console.log(object) // Object {name: "Andrew", getName: function getName()}
console.log(object2, 'object2') // ObjectClass {name: "Andrew", constructor: Object}
I've used codesandbox for creating this code and I get there next responses , I'm little bit confused , because I thought that object
and object2
will be the same . {}
thought that it is the same as new Object()