Thoughts #5: Understanding JS Enumerable Properties Descriptor

While doing Understanding JavaScript For Loops learning-note lesson, knowledege of enumerable property is important because only enumerable properties are listed using loop and Object.keys(). When an object is created using an object initializer, its descriptor properties are set behind the seen and not obvious. Understanding of enumerable property is important working with loops & iteration, and JSON.stringify() method.

Enumerable properties show up in for…in loops (once for each property) unless the property’s name is Symbol.

Realizing that I hadn’t comprehend the JS enumerable descriptor property fully, I decided to deep dive into enumerable property descriptor with a goal to answer what is JS enumerable property?

What is JS Enumerable Property?

From this Hashnode discussion note by Kelo Patrov, I got an general idea that how object property descriptor (eg. writable, enumerable & configurable) are set when an object is created with object initializer or Object.defineProperty() method. Simply, when an object is created with Object initializer all property descriptors are set to true by default, where as object created with Object.defineProperty() method are set to false by default, unless explicitly defined otherwise. This prompted me to fully understand how objects are created with Object.defineProperty() method and its descriptors attributes are defined and modified.

Search for Useful Resources

Before I venture into a new learning topic, I do google search starting with MDN JS Documentation and then other tutorial blogs. Because Object descriptor property is described as advanced topic ( Dr Rauschmayer) I couldn’t find many simple tutorials on this topic. After some research, I identified following resources:

My original plan was to do this topic quick and move to the next one. However, I happen to spend much more time than I had anticipated. For my learning purposes, I found the three tutorials from CodeKraft and MDN Documentation very useful.

What is Next?

My original plan was to start learning DOM after this topic, however I thought to continue other object properties – Accessors (getters & setters) before moving to DOM. I have identified the following resources on learning Property Accessors including one use case by Lea Verou: