// Automatically escapes all backslashes in the RegExp when stringifyingconststringWithEscapedBackslashes=/\\\\\\this \\\string has lots\ of \\\\backslashes for \\ some reason./.source;// yields "\\\\\\\\\\\\this \\\\\\string has lots\\ of \\\\\\\\backslashes for \\\\ some reason."
I'm a fan of Open Source and have a growing interest in serverless and edge computing. I'm not a big fan of spiders, but they're doing good work eating bugs. I also stream on Twitch.
Hmm. I verified that the MDN isn't just out of date by testing in Chrome. I can't remember the context I was using that snippet in precisely, but I do remember it was designed to run in IE10+, Chrome, and Firefox.
I may have just been using it so I wouldn't have to escape all my backslashes for a string.
I'm a fan of Open Source and have a growing interest in serverless and edge computing. I'm not a big fan of spiders, but they're doing good work eating bugs. I also stream on Twitch.
Another one I just remembered:
Wow
It looks like the escaping only works in FireFox according to the MDN docs, RegExp.prototype.source (see Browser Compatibilty section).
Hmm. I verified that the MDN isn't just out of date by testing in Chrome. I can't remember the context I was using that snippet in precisely, but I do remember it was designed to run in IE10+, Chrome, and Firefox.
I may have just been using it so I wouldn't have to escape all my backslashes for a string.
I tried in Chrome yesterday and it doesn't error out, but it just doesn't escape.