r/learnjavascript • • Oct 11 '20

JavaScript can keep you safe

Post image
1.0k Upvotes

87 comments sorted by

View all comments

5

u/zigzeira Oct 11 '20

ES5

2

u/Macaframa Oct 11 '20

What features in es6 would you use to make this different in any way?

4

u/james527 Oct 11 '20

const still_alive = true;

Make that one immutable.

2

u/Macaframa Oct 11 '20

Const is not immutable per se but go off.

1

u/james527 Oct 12 '20

True, it's just the reference that's immutable.

If we were referencing an array here, instead of a boolean, we'd still be able to change the contents of the array. We just wouldn't be able to reassign the still_alive variable to anything else.