Categories
JavaScript Answers

How to get objects value if its name contains dots with JavaScript?

Spread the love

Sometimes, we want to get objects value if its name contains dots with JavaScript.

In this article, we’ll look at how to get objects value if its name contains dots with JavaScript.

How to get objects value if its name contains dots with JavaScript?

To get objects value if its name contains dots with JavaScript, we can use square brackets.

For instance, we write

const smth = myData.list[0]["points.bean.pointsBase"][0].time;

to put "points.bean.pointsBase" in square brackets to access this property in the myData object.

Conclusion

To get objects value if its name contains dots with JavaScript, we can use square brackets.

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 *