Js, Property Descriptors

Sometimes you may want your variable to act like a constant variable or something, well we can achieve such a behaviour by using writable property descriptor Object Dot defineProperty Let’s see it in action, first we need an object; var b = {}; Then, let’s add a property to this objec,we can use the built-in defineProperty() function of the Object to achieve this : Object.defineProperty(b, "a", { value: "b letter", writable: false, configurable: true, enumerable: true }); b....

3 min · Ahmet Gokdayi