In the same way that dojo has array functions that provide forEach and map functions to older browsers, does the Dojo Toolkit offer a solution for Object.keys and Object.values?
In the same way that dojo has array functions that provide forEach and map functions to older browsers, does the Dojo Toolkit offer a solution for Object.keys and Object.values?
Share Improve this question asked Oct 23, 2013 at 14:52 Ray WadkinsRay Wadkins 9141 gold badge7 silver badges16 bronze badges 3- possible duplicate of How can you iterate over an object (associative array) in Dojo? – Francisco Paulo Commented Oct 23, 2013 at 15:04
-
It is a possible duplicate, but that answer's link is out of date and it just covers
forIn
. This question is asking specifically aboutkeys
andvalues
. – Thomas Upton Commented Oct 23, 2013 at 19:24 - 1 Yeah, I know how to iterate over an object, that wasn't the point. – Ray Wadkins Commented Oct 25, 2013 at 3:16
1 Answer
Reset to default 8I think you might be looking for dojox/lang/functional/object
, which contains methods to get an object's keys and values. Since the documentation is pretty lacking, here's a fiddle.
require([
'dojox/lang/functional/object'
], function(o) {
var obj = {
key: 'value1',
name: 'myName',
numeric: 1,
'hello': 'there'
};
console.log(o.keys(obj));
console.log(o.values(obj));
});
There are also functions to filter
, map
, and iterate each attribute in (forEach
) objects in that module.