December 2019
Beginner
464 pages
10h 31m
English
In This Chapter
• Learn the difference between data properties and accessor properties
• Learn about getters and setters
• Identify when to use an accessor property vs. a data property
The properties we have been working with so far are known as data properties. These are the properties where we give them a name and assign a value to them:
let foo = { a: "Hello", b: "Monday"; }
To read back the value, all we do is just access it directly:
console.log(foo.a);
Writing a value to this property is sorta what we would expect as well:
foo.a = "Manic";
Outside of setting and reading a value, there really isn’t much more we can do. That is the sad tale of a data property. Now, as part of reading ...