String.prototype.replaceAll() is a convenience method for text processing. André Bargull [:anba] contributed the implementation of this feature. It's in Nightly now.
The proposal is at Stage 3 of the TC39 Process[1]. Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1540021 Proposed standard: https://tc39.es/proposal-string-replaceall/ Proposal repository: https://github.com/tc39/proposal-string-replaceall MDN: no page yet (dev-doc-needed is set on the bug) Platform coverage: All, Nightly only, no pref DevTools bug: N/A Other browsers: Recently implemented in V8[2]. Not in JSC yet.[3] Testing: Landed with automated tests.[4] test262 will supply independent tests later. Use cases: This is a quality-of-life feature. `string.replace(searchFor, replacement)` has already been around for many years, but replaceAll is what you usually mean. Spot the difference: js> "words with spaces between".replace(" ", "-") "words-with spaces between" js> "words with spaces between".replaceAll(" ", "-") "words-with-spaces-between" The old-school workaround is to pass a RegExp with the `g` flag as the first argument, or use `.split(" ").join("-")`. But neither hack is exactly obvious--one StackOverflow answer explaining how to do it has 4,000+ upvotes.[5] The new method is clearer and more discoverable. [1]: https://tc39.es/process-document/ [2]: https://bugs.chromium.org/p/v8/issues/detail?id=9801 [3]: https://bugs.webkit.org/show_bug.cgi?id=202471 [4]: https://phabricator.services.mozilla.com/D51842 [5]: https://stackoverflow.com/a/1144788/94977 -j _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform