Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Can you explain me what is the difference between these two objects? How can I add word 'Product' at the beginning of the object?

Array(2)
0: {status: "published", _id: "5ff584e56153e75706790fa9", title: "bbbbb", imageUrl: "images/2021-01-06T11:59:42.006Z-7pIfYwyRCL8.jpg", price: 3333111,?…}

1: Product?{_id: "5ff58d1c6153e75706790faa", title: "5555555", imageUrl: "images/2021-01-06T11:30:26.521Z-7pIfYwyRCL8.jpg", description: "sddsdsd", price: 3333,?…}length: 2

Also, the image: enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
163 views
Welcome To Ask or Share your Answers For Others

1 Answer

Thats because this second one was most likely created using

const product = new Product(...)

while first one

const product = {...}

And so the type doesn't match

It's similar to this case

const someMap = new Map();
someMap.set("hello", "world");

const someObject = {
    hello: "world",
}

someMap == someObject // false
someMap === someObject // false

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...