Email or username:

Password:

Forgot your password?
Darius Kazemi

ES2021 was just approved and is finally, FINALLY shipping with String.prototype.replaceAll. So

'falafel'.replace(/l/g,'b')
'falafel'.replaceAll('l','b')

both give you `fabafeb`.

No more regex needed just to get the "greedy" flag in there!

h3manth.com/ES2021/#stringprot

7 comments
Mina

@darius how many years until the JavaScript standard library is usable enough to not require a million npm packages installed?

Darius Kazemi

@meena I think it's already there and we just have some very bad habits ingrained (and lots of very common dependencies don't use the new JS syntax themselves, so then THEY install those dependencies even if you don't)

Mina

@darius i think I'm mostly thinking of mutable by default (array) functions
which seems like a bad thing in… most languages

Touk

@darius 1. Nice! Shouldn't need a regex just for that.
2. I saw the URL and at first thought you hashtagged #stringprototypereplaceall (very niche of you)

Go Up