add Ox.zipObject

This commit is contained in:
rolux 2014-08-18 19:09:41 +02:00
parent f01456e475
commit b10d454d2c

View file

@ -202,3 +202,16 @@ Ox.unserialize = function(string, isJSON) {
});
return ret;
};
/*@
Ox.zipObject <f> Takes a keys and a values array, returns a new object
> Ox.zipObject(['a', 'b'], [1, 2])
{a: 1, b: 2}
@*/
Ox.zipObject = function(keys, values) {
var object = {};
keys.forEach(function(key, index) {
object[key] = values[index];
});
return object;
};