我想在 java 脚本中将数组转换为对象 [["key1","ans1"],["key2","ans2"] ]=> {key1:"ans1",key2:"ans2"}
I want to convert array to object in java script like[ ["key1","ans1"],["key2","ans2"] ]=> {key1:"ans1",key2:"ans2"}
我想在 javascript 中将数组转换为对象,例如
[["key1","ans1"],["key2","ans2"]]
=> {key1:"ans1",key2:"ans2"}
给你;
let res = {}
let arr = [["key1","ans1"],["key2","ans2"]]
for (let i = 0; i < arr.length; i++) {
res[arr[i][0]] = arr[i][1]
}
console.log(res)
如需说明请留言
我想在 javascript 中将数组转换为对象,例如
[["key1","ans1"],["key2","ans2"]]
=> {key1:"ans1",key2:"ans2"}
给你;
let res = {}
let arr = [["key1","ans1"],["key2","ans2"]]
for (let i = 0; i < arr.length; i++) {
res[arr[i][0]] = arr[i][1]
}
console.log(res)
如需说明请留言