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.