我需要转换
[{"document_id":"1"},{"document_id":"4"},{"document_id":"3"},{"document_id":"10"},{"document_id":"11"},{"document_id":"2"}]
要
["1","4","3","10","11","2"]
答案 0 :(得分:8)
你可以使用:
{{1}}
答案 1 :(得分:0)
尝试使用for in
循环,.splice()
,Object.keys()
var arr = [{
"document_id": "1"
}, {
"document_id": "4"
}, {
"document_id": "3"
}, {
"document_id": "10"
}, {
"document_id": "11"
}, {
"document_id": "2"
}];
for (var prop in arr) {
arr.splice(prop, 1, arr[prop][Object.keys(arr[prop])[0]]);
};
console.log(arr);