Use []
notation for string representations of properties:
console.log(obj[name]);
Otherwise it’s looking for the “name” property, rather than the “a” property.
Use []
notation for string representations of properties:
console.log(obj[name]);
Otherwise it’s looking for the “name” property, rather than the “a” property.