News for hackers. Stuff that matters.
Re:How necessary are var, let, and const? by bmeck on Monday June 01, 2015 @08:51AM (#9638130)
const can be used to denote that a reference to the variable is being passed around and should not change for the lifetime of a scope.

    function f() {
      const queue = [];
      consumer(queue);
      return queue;
    }
It could be important to note that removing const has benign effect, but that it is there to ensure a programmer does not change the value of queue between `consumer(queue)` and `return queue`. Easily reasoned about, but extra safeguards from introducing bugs is always nice.
Re:How necessary are var, let, and const? by thomasfoster96 on Monday June 01, 2015 @11:11AM (#9639168)
I'm not sure I quite understand your point - while it's true that the variable called queue won't be reassigned, const would still allow elements and properties to be added to queue.
Re:How necessary are var, let, and const? by bmeck on Tuesday June 02, 2015 @11:09AM (#9646324)
const is not about immutability in JS.
Re:How necessary are var, let, and const? by thomasfoster96 on Wednesday June 03, 2015 @09:17AM (#9652266)
I know that - but the previous comment made it sound as though it did mean immutability.
Re:How necessary are var, let, and const? by EugeneOZ on Monday June 01, 2015 @10:56AM (#9639013)
Ironically enough, but your example shows where const is shouldn't be used as guarantee of immutability: https://t.co/JIQozGe7Md
Re:How necessary are var, let, and const? by agumonkey on Monday June 01, 2015 @12:47PM (#9640069)
Isn't that a typical "corner case" in the understanding of dynamic languages bindings ? I think I've seen the same question pop about python. The array binding is constant, its content isn't.
Re:How necessary are var, let, and const? by EugeneOZ on Monday June 01, 2015 @02:41PM (#9641096)
if value of constant can be changed, it's not constant. In my understanding. And by Wikipedia: http://en.wikipedia.org/wiki/Constant_(computer_programming)
Re:How necessary are var, let, and const? by agumonkey on Monday June 01, 2015 @03:11PM (#9641340)
That's typical computer lingo / semantic issue. the `const` mean shallow/pointer constant, not deep/structurally constant.
Re:How necessary are var, let, and const? by bmeck on Tuesday June 02, 2015 @11:10AM (#9646329)
const is not about immutability in JS.
Re:How necessary are var, let, and const? by digi_owl on Monday June 01, 2015 @10:02AM (#9638602)
I guess you can say that they are there to allow the compiler to check the intent of the programmer.