Skip to content

Instantly share code, notes, and snippets.

@Ginden
Last active July 10, 2018 10:00
Show Gist options
  • Save Ginden/bf628e88be0886ac8340bdecf16e98f3 to your computer and use it in GitHub Desktop.
Save Ginden/bf628e88be0886ac8340bdecf16e98f3 to your computer and use it in GitHub Desktop.
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