JavaScript: using constructor without operator ‘new’

In general, if something is documented as being a constructor, use new with it. But in this case, RegExp has a defined “factory” behavior for the situation where you’ve called it as a function instead. See Section 15.10.3 of the ECMAScript (JavaScript) specification (that links to the outgoing spec; the section number is the same … Read more