To add from the given answer just a few guidelines for accessing Object Properties here are some tips that would help you in the future.
1. Dot property accessor
This common way to access the property of an object is the dot property accessor syntax:
expression.identifier
const hero = {
name: 'Batman'
};
// Dot property accessor
hero.name; // => 'Batman'
1.1 Dot property accessor requires identifiers
-The dot property accessor works correctly when the property name is a valid identifier. An identifier in JavaScript contains Unicode letters, $, _, and digits 0..9, but cannot start with a digit.
const weirdObject = {
'prop-3': 'three',
'3': 'three'
};
weirdObject.prop-3; // => NaN
weirdObject.3; // throws SyntaxError: Unexpected number
- To access the properties with these special names, use the square brackets property accessor (which is described in the next section):
const weirdObject = {
'prop-3': 'three',
'3': 'three'
};
weirdObject['prop-3']; // => 'three'
weirdObject[3]; // => 'three'
2. Square brackets property accessor:
-expression[expression]
const property = 'name';
const hero = {
name: 'Batman'
};
// Square brackets property accessor:
hero['name']; // => 'Batman'
hero[property]; // => 'Batman'
3. Object destructuring:
- const { identifier } = expression;
const hero = {
name: 'Batman'
};
// Object destructuring:
const { name } = hero;name; // => 'Batman'
Note that you can extract as many properties as you’d like:
const { identifier1, identifier2, .., identifierN } = expression;
file.['en-US'].urllooks like a simple typo, did you mean to dofile['en-US'].urlIOW: you put an extra dot in there.