Isn’t a JavaScript “Object” just a dictionary? Why is there a fancy name for Object Literal Notation? And for JavaScript Object Literal Notation, you can only refer to the object’s property’s value with Object.property and not Object[property] (as you would do in Python)?
Isn’t a JavaScript Object just a dictionary? Why is there a fancy name for
Share
Javascript’s “Object Literal Notation” is simply the syntax that javascript accepts for a statically declared data structure. While a javascript object can be used similarly to what is called a dictionary in other languages, “Object Literal Notation” is just a static declaration syntax. It would typically look something like this:
The term “Object Literal Notation” does not refer to all possible ways that you can address an object with javscript code. You don’t use either the
Object.propertyorObject[property]syntax to define a property in a static object declaration except as the value part of a declaration where the Object is some other object.This article has a good reference on the Object Literal syntax under the heading Basic Syntax.