Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dojo Equivalent for Object.keys

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?

like image 451
Ray Wadkins Avatar asked Feb 15 '23 22:02

Ray Wadkins


1 Answers

I 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.

like image 80
Thomas Upton Avatar answered Feb 23 '23 08:02

Thomas Upton