Skip to main content
7 events
when toggle format what by license comment
Oct 30, 2017 at 6:11 vote accept vivek
Oct 21, 2014 at 9:35 comment added Ben Doesn't seem to with a plain object. However the callback function is called when iterating over the node.attributes object. See my updated answer for a solution without using reduce at all.
Oct 21, 2014 at 7:56 comment added Johan Does it really work? jsfiddle.net/55gx9q47
Oct 21, 2014 at 2:09 comment added vivek Seems a elegant approach. But I have a doubt in mind, reduce will be called for each element and hence will be a overhead as compared to simple attribute access.
Oct 20, 2014 at 22:05 history edited Ben CC BY-SA 3.0
Simplify.
Oct 20, 2014 at 22:01 comment added Ben Johan, node.attributes is an object, not an array; so we have to borrow the reduce method from the array prototype. If it were, you could simply do return node && node.attributes.reduce(function(list, attribute) { // ... . :-)
Oct 20, 2014 at 13:43 history answered Ben CC BY-SA 3.0