I get an error with the following code:
Array.prototype.remove = function(value) {
return this.filter((element) => element != value); //TypeError: this.filter is not a function
}
([2, 3, 8, 9]).remove(3);
Can someone explain why? I do not get the same results when using a String function:
String.prototype.toTitleCase = function() {
return this.replace(/\b\w+/g,
(txt) => (txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase())
); // Works perfectly with no errors
}
I am using the latest version of Firefox (75.0, 64-bit)