标签:dev har push 数组 type ati pre init console
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>
标签:dev har push 数组 type ati pre init console
原文地址:https://www.cnblogs.com/rongyao/p/11498636.html