DEV Community

Cover image for How to Access JavaScript Arrays in Objects
Asela
Asela

Posted on

1

How to Access JavaScript Arrays in Objects

Have an Object that contains an array, Then How to Access Arrays in Object,

Here is the simple Solution

Here's my Object

const myobj = {
"name":"John",
"age":30,
"cars":["Ford", "BMW", "Fiat"],
"PetName":"Dogee"
}
Enter fullscreen mode Exit fullscreen mode

Think if you need to access value in cars array. Just Code Like this

myobj.cars[value_index]
Enter fullscreen mode Exit fullscreen mode

So simple, isn't it? So Keep Following for tips like this.

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay