Categories
JavaScript Answers

How to set a JavaScript object values dynamically?

Spread the love

To set a JavaScript object values dynamically, we can use the square bracket notation.

For instance, we write

myObj[prop] = value;

to set the myObj‘s prop property to value.

prop is a string with the property name.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *