Advertisement
Guest User

Untitled

a guest
Apr 25th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. // Is there a way to define immutable parameters in ES6?
  2.  
  3. const inc = x => {
  4. x++; // Oh no, you modified x!
  5. return x;
  6. }
  7.  
  8. // Is it better to reassign to const (if it should be constant, of course)?
  9.  
  10. const inc = x => {
  11. const x = x;
  12.  
  13. x++; // Booop... x is readonly!
  14. return x;
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement