1
我需要提取,從這個陣列如何從對象數組中提取鍵作爲數組?
const mylist = [
{
"key": "",
"doc_count": 3
},
{
"key": "IT",
"doc_count": 1
}
]
的key
值的數組:
["", "IT"]
今天我用一個簡單的方法
finalList = []
_.forEach(myList, function (element) {
finalList.push(element.key)
})
,但我看到lodash
有幾種方法,其中差不多我的情況:_.zip
/_.unzip
,_.fromPairs
/_.toPairs
和_.zipObject
有沒有一種方法來簡化根據lodash
方法的代碼?