Reputation: 87
What is the difference fundamental between an call with {object.object}
and a call with Object.values(object)
?
Why sometimes, i use, for exemple, {user.user.firstname}
and sometimes i use Object.values(user.user)
?
Upvotes: 0
Views: 40
Reputation: 20753
Object.values()
will return an array of the object's own enumerable property values, where as {object.key}
will return you the value of that specific key.
For eg: if your object is:
let user = {
user: {
firstname: "foo",
lastname: "bar"
}
}
Then the output for Object.values(user.user)
will be:
["foo", "bar"]
and for user.user.firstname
it will be:
foo
Upvotes: 1