I have an object that has properties, but when I try to access them, it always returns undefined.
Using Chrome, I attached the object to window and in the console, if I do, window.country
It returns this object:
[ Object
currency_code: null
iso: "USA"
iso3: "USA"
name: "USA"
states: Array[51]
__proto__: Object
]
However, when I try to access a property, such as window.country.iso it’s undefined. Any ideas why this would be?
Thank you!
Your
window.countryobject is actually an array.Chrome’s console is showing you that. As you can see your object is wrapped in
[], that means it’s in an array.Try to access it like:
window.country[0].iso.