【发布时间】:2012-09-14 12:26:30
【问题描述】:
我想做以下事情:
// an object
var object = {
one: null,
two: null,
three: null
};
// an array
var array = ['this is one', 'this is two', 'this is three'];
我现在想将它们合并在一起,所以我得到了;
var merged = {
one: 'this is one',
two: 'this is two',
three: 'this is three'
};
我不想只使用纯 javascript (ECMA5) 的任何第三个库。
那么诀窍是什么?
问候, 博多
【问题讨论】:
-
你的问题非常不清楚,请试着解释一下你到底想做什么。
-
您想在打印时查看所有属性吗?你用什么命令来打印?
-
+1 给@Jeroen。 “平行”是什么意思?
-
你能告诉我们参数是什么吗?
-
根据定义,对象中键的顺序是未定义的,因此这至少在某些方面会很麻烦。还有其他方法可以采购您的配对吗?
标签: javascript arrays object for-loop