The Object.defineProperties() method is used to define new or modify existing properties directly on an object and returning the object. Let’s define multiple properties on an empty object,
1 2 3 4 5 6 7 8 9 | const newObject = {}; Object.defineProperties(newObject, { newProperty1: { value: 'John', writable: true }, newProperty2: {} }); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.