最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Dojo Equivalent for Object.keys - Stack Overflow

programmeradmin0浏览0评论

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 about keys and values. – 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
Add a ment  | 

1 Answer 1

Reset to default 8

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.

发布评论

评论列表(0)

  1. 暂无评论