gilbert189 — 11/12/2022, 7:07:49 AM

why the flip is there both String.prototype.replace and String.prototype.replaceAll in JavaScript

♥ 0 ↩ 0 💬 6 comments

comments

lily:

ecma forgot about the /g switch

11/12/2022, 10:34:39 AM
pkmnq:

Task 1: Make a function that removes a certain string from another string.

11/12/2022, 2:03:36 PM
pkmnq:

i checked, it’s for things like this where you’re not sure about what you’re replacing

String.prototype.removeAll = function (remove) {
  return this.replaceAll(remove, "")
}
11/12/2022, 7:20:58 AM
lily:

why should that matter

11/12/2022, 5:10:44 PM
pkmnq:

Try doing it without replaceAll

11/12/2022, 5:32:34 PM
lily:

ok

11/12/2022, 8:14:53 PM