Example doesn't work correctly #1

rwaldron opened this Issue Feb 26, 2013 · 4 comments

2 participants


Hi! Neat function.

The example looks for matchesSelector on document... needs to look on document.documentElement.

Also, check this out:

var matchesSelector = ["m","webkitM","mozM","msM","oM"].reduce(function(p, v) {
  return (document.documentElement[v + p] && v + p) || p;
}, "atchesSelector");

document.body[matchesSelector]("body"); // true

Fixed. Thanks for pointing this out!

About the reduce function, it's not similar to the or: or stops looping as soon as possible. It's a mix between some and filter.

@ralt ralt closed this Feb 27, 2013

I agree, and I like the "stop iterating after the first truthy thing is found" semantics.


Just wanted to thank you for this brief conversation. I was motivated to collect more use cases and I'm pleased to say that we accepted Array.prototype.find and Array.prototype.findIndex into the ES6 spec today. Notes will be published on Monday :)


Yay! Glad to know I helped a little bit in making ES6 better :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment