Skip to content

Instantly share code, notes, and snippets.

@mrspeaker
Created March 7, 2015 20:46
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 mrspeaker/e9a68d4c96abdbe7f2bb to your computer and use it in GitHub Desktop.
Save mrspeaker/e9a68d4c96abdbe7f2bb to your computer and use it in GitHub Desktop.
Immutable parameters in ES6?
// Is there a way to define immutable parameters in ES6?
const inc = x => {
x++; // Oh no, you modified x!
return x;
}
// Is it better to reassign to const (if it should be constant, of course)?
const inc = x => {
const x = x;
x++; // Booop... x is readonly!
return x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment