【发布时间】:2017-02-15 16:26:24
【问题描述】:
我需要键 country_code 和 language_code 的值。
我试过了
sourceLanguageArray[0].$.country_code;
sourceLanguageArray[0].$.language_code;
我得到错误:
console.log(sourceLanguageArray[0].$.country_code);
^
ReferenceError: sourceLanguageArray is not defined
这是数据结构的代码和控制台日志的样子:
source_language (includes country_code and language_code)
const sourceLanguageArray = _.map(ontomlClass, 'source_language');
console.log(sourceLanguageArray);
// => [ [ { '$': [Object] } ], [ { '$': [Object] } ],[ { '$': [Object] } ] ]
// => [ { '$': [Object] } ]
console.log(sourceLanguageArray[0]);
// => [ { '$': { country_code: 'US', language_code: 'en' } } ]
【问题讨论】:
标签: javascript arrays object key