Example:
var o = { x : 1}
That that’s means?
Example:
var o = { x : 1}
That that’s means?
It’s like the =
, but for object properties. Here you have an object with a property named x
, and that x
has a value of 1
.
You’re defining an object called “o”, that contain key:value pairs.
In your example, you have one key called “x” with a value of 1.
such that:
o.x = 1 // here, you're asking what is the value of the key "x" in object "o"
// you can also ask for the object what are it's keys
Object.keys(o);
// returns an array with one element ["x']
// you can also ask what are it's values
Object.values(o);
// returns an array [1]
You can define multiple keys, like
var customer = {name: "john", lastname: "doe"}
customer.name // returns "john"
customer.lastname // returns "doe"
Thanks u so much for the explanation!
Thank u so much for taking the time to answer!