JS 过滤数组里对象的某个属性
Posted rongyao
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JS 过滤数组里对象的某个属性相关的知识,希望对你有一定的参考价值。
1 <!DOCTYPE html> 2 <html lang="en"> 3 4 <head> 5 <meta charset="UTF-8"> 6 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 7 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 8 <title>Document</title> 9 </head> 10 11 <body> 12 13 <script> 14 var newArray = [ 15 name: "aaa", 16 value: 0, 17 height: 1 18 , 19 20 name: "ddd", 21 value: 3, 22 height: 1 23 , 24 25 name: "bbb", 26 value: 1, 27 height: 1 28 , 29 30 name: "eee", 31 value: 4, 32 height: 1 33 , 34 35 name: "ccc", 36 value: 2, 37 height: 1 38 39 ]; 40 41 42 var newArray2 = []; 43 for (var i = 0; i < newArray.length; i++) 44 var newObject = ; 45 newObject.name = newArray[i].name; 46 newObject.height = newArray[i].value; 47 newArray2.push(newObject); 48 49 console.log(newArray2) 50 51 52 // for (var i = 0; i < 6; i++) 53 // setTimeout(function () 54 // console.log(i); 55 // , 0) 56 // 57 </script> 58 59 </body> 60 61 </html>
以上是关于JS 过滤数组里对象的某个属性的主要内容,如果未能解决你的问题,请参考以下文章