Why is the third option is correct answer? If this is correct, it means that we can use other three forms of calling _num. Why do we can use console.log(tempObj[‘num’])? I see this form of calling first time. Why do we use square brackets here?
the square brackets is known as associative array notation, in JS objects are associative arrays (and vice versa)
this notation is useful if you have a string (which could come for user input for example) or you have a property with a space in the name (then you have to use associative array notation, you can’t use the dot notation)
after a property (greeting) there should be a colon, not an equal sign.
however, the last option is not displaying correctly (which is why i can understand you are confused), the js bit is from codecademy, indicating the syntax is Javascript, normally this shouldn’t be displayed, i will report it.
hopefully i explained square brackets earlier
we can, except in the answer you see let at the beginning of the line, when adding to an existing object, let shouldn’t be used (let should only be used when declaring variables)
Hm, now its better, but now I cannot understand why it is correct to use quotes in the last answer. We use quotes when we have a space between the words, or special characters, isn’t it?
when using the associative array notation, you have to use a string. The associative array notation can always be used, you have to use it when dealing with spaces in your key/property.