Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting a Custom Objects properties by string var [duplicate]

People also ask

How do you copy properties from one object to another JS?

The Object. assign() method is used to copy the values of all enumerable own properties from one or more source objects to a target object. In the code above, we changed the value of the property 'b' in objCopy object to 89 and when we log the modified objCopy object in the console, the changes only apply to objCopy .

How do you access variables in objects?

Use the member-access operator ( . ) between the object variable name and the member name. If the member is Shared, you do not need a variable to access it.


Simply use myObject['thing'].


You could use:

myObject[propertyString] ;