Tin mới
JavaScript: Scripting language
Web APIs: Programming interfaces
Structuring content with HTML module
Dynamic scripting with JavaScript module
The RegExp object overrides the toString() method of the Object object; it does not inherit Object.prototype.toString(). For RegExp objects, the toString() method returns a string representation of the regular expression
Empty regular expressions and escaping
Since toString() accesses the source property, an empty regular expression returns the string "/(?:)/", and line terminators such as \n are escaped. This makes the returned value always a valid regex literal.
This page was last modified on Aug 3, 2025 by MDN contributors.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.