Categories
JavaScript Answers

How to access JSON property with “-” dash with JavaScript?

Spread the love

Sometimes, we want to access JSON property with "-" dash with JavaScript.

In this article, we’ll look at how to access JSON property with "-" dash with JavaScript.

How to access JSON property with "-" dash with JavaScript?

To access JSON property with "-" dash with JavaScript, we can use a string.

For instance, we write

const profileId = jsonObj["profile-id"];

to access the profile-id property from jsonObj with jsonObj["profile-id"].

Conclusion

To access JSON property with "-" dash with JavaScript, we can use a string.

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 *