共计 378 个字符,预计需要花费 1 分钟才能阅读完成。
let objectTest = [{"instanceClass":"AAAAA"},
{"instanceClass":"BBBBB"},
{"instanceClass":"CCCCC"}
]
问题:将 objectTest 数据格式改为 [“AAAAA”,”BBBBB”,”CCCCC”]
答:
1、let testArray = Array.from(objectTest,({instanceClass})=> instanceClass);
console.log(testArray); //[["AAAAA","BBBBB","CCCCC"]]
2、let testArray1 = objectTest.map((item)=> Object.values(item)[0] )
console.log(testArray1); //[["AAAAA","BBBBB","CCCCC"]]
正文完
发表至: javascript
2019-10-31