Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Array.prototype.replace = function replace(map) {
const newArray = [];
for(const [index, value] of this.entries()) {
if(map.has(value)) {
newArray[index] = map.get(value);
} else {
newArray[index] = value;
return newArray;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.