🏠 New in Low Baseline Support: RegExp.escape()
May 1, 2025
The RegExp.escape() static method takes a string and replaces any characters that are potentially special characters of a regular expression with equivalent escape sequences. For example, RegExp.escape("[abc]") returns "\\[abc\\]".
Source features
javascript.builtins.RegExp.escape[mdn]