February 2019
Beginner
694 pages
18h 4m
English
When working with JavaScript objects, it is fairly common to define them with property names that are strings, as can be seen in the following code:
let normalObject = {
id : 1,
name : "test"
}
let stringObject = {
"testProperty": 1,
"anotherProperty": "this is a string"
}
Here, we have defined an object named normalObject that has an id and a name property. We can access these properties by referencing normalObject.id, or normalObject.name, as we have seen many times before. Note, however, the minor change in the definition of the stringObject object. Here, each property name is enclosed in double quotes ( "" ), making it a string property. We can reference these string properties in two ways:
let testProperty = stringObject.testProperty; ...
Read now
Unlock full access