use*_*est 4 javascript arrays key
什么是将键和值分成两个不同数组的最佳方法,以便 -
var data = {"A Key": 34, "Another Key": 16, "Last Key": 10};
Run Code Online (Sandbox Code Playgroud)
会成为这个 -
data1 = ["A Key", "Another Key", "Last Key"];
data2 = [34, 16, 10];
Run Code Online (Sandbox Code Playgroud)
谢谢.
var data = {"A Key": 34, "Another Key": 16, "Last Key": 10};
var data1 = [],
data2 = [];
for (var property in data) {
if ( ! data.hasOwnProperty(property)) {
continue;
}
data1.push(property);
data2.push(data[property]);
}
Run Code Online (Sandbox Code Playgroud)
data没有明确地具有此属性(即不高于原型链),请跳过此迭代.| 归档时间: |
|
| 查看次数: |
4882 次 |
| 最近记录: |