When implementing a router, I ran into an interesting issue regarding
RegExp.prototype.exec(). Let's look at an example.
var regexp = /\/foo\/bar/; var match = regexp.exec('/foo/bar/'); //match -> ["/foo/bar"] //Object.keys(match) -> ["0", "index", "input"]
Huh, so match contains the matched text, but unlike a typical array it also contains index and input properties. Since arrays are objects this is of course possible but nonetheless suprising. It's gotchas such as these that define mastery of the language, for better or worse.