遍历json数组中的json对象(键未知)

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
var arrs = [{"a":"a"},{"b":12},{"c":31},{"d":23},{"e":34}]
for(let arr of arrs){
console.log(Object.keys(arr))// 键
console.log(arr[Object.keys(arr)])//值
}
console.log("==============")
for(let arr in arrs){
console.log(arrs[arr])//下标
}
</script>
</body>
</html>
posted @ 2021-02-22 09:38  想学前端的小李  阅读(125)  评论(0)    收藏  举报