📜  使用 for 循环 (for) 迭代或循环遍历数组的元素: - 无论代码示例

📅  最后修改于: 2022-03-11 15:00:42.747000             🧑  作者: Mango

代码示例1
var keys = Object.keys(o);   // Get an array of property names for object o
var values = []              // Store matching property values in this array
for(var i = 0; i < keys.length; i++) {  // For each index in the array
    var key = keys[i];                  // Get the key at that index
    values[i] = o[key];                 // Store the value in the values array
}