JS Coding Questions Logo
JS Coding Questions
#265💼 Interview💻 Code

How do you define multiple properties on an object

Advertisement

728x90

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,

javascript
1const newObject = {};
2
3Object.defineProperties(newObject, {
4  newProperty1: {
5  value: "John",
6  writable: true,
7  },
8  newProperty2: {},
9});

Advertisement

Responsive Ad
🎯 Practice NowRelated Challenge

JavaScript Coding Exercise 8

Test your knowledge with this interactive coding challenge.

Start Coding

Advertisement

728x90
265of476