Skip to content

Instantly share code, notes, and snippets.

@buglessir
Created March 23, 2019 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buglessir/a4e2c2080cf08f262517b62596e103f5 to your computer and use it in GitHub Desktop.
Save buglessir/a4e2c2080cf08f262517b62596e103f5 to your computer and use it in GitHub Desktop.
function mutation(originalArray) {
// directly mutating/modifying the original array
originalArray[0] = "new value";
return originalArray;
}
var array = ["some value", "another value"];
alert("Return from mutation " + mutation(array));
alert("Array: " + array + " (original array has been altered).");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment