Tutorial about how to create immutable, enumerable and cofigurable object properties in javascript.
Objects are one of the main parts of Javascript. JS syntax for Objects is really concise and easy to use, so we are constantly creating objects and using them as hashmaps effortlessly.
But, do you know that all the object properties in the example above are enumerable, writable and configurable? I mean:
- Enumerable: I can access to all of them using a for..in loop. Also, enumerable property keys of an object are returned using Object.keys method.
- Writable: I can modify their values, I can update a property just assigning a new value to it: ob.a = 1000;
- Configurable: I can modify the behavior of the property, so I can make them non-enumerable, non-writable or even non-cofigurable if I feel like doing so. Configurable properties are the only ones that can be removed using the delete operator.
Your new post is loading...