JavaScript: `new RegExp('hi')` versus `RegExp('hi')`? [duplicate]
问题 This question already has answers here : JavaScript: using constructor without operator 'new' (2 answers) Closed 4 years ago . What is the difference between RegExp('hi') and new RegExp('hi') ? Does the new keyword do anything here? 回答1: It is identical The RegExp constructor is the %RegExp% intrinsic object and the initial value of the RegExp property of the global object. When RegExp is called as a function rather than as a constructor, it creates and initializes a new RegExp object. Thus