Const is fucking useful

Stop being an asshole.

  1. const stops you, or anyone else on your fucking team, from reassigning a variable that should remain constant. It doesn’t suggest immutability, and it was never about immutability. There were other additions to the spec that gave us immutability. If you want a variable declaration that is immutable, please try to find a productive way to suggest we need it, and make a reasonable case as to why, instead of calling the work of hundreds of people (present company excluded) fucking useless. You know what was fucking useless? Your post. 
    const myConstant = 'do not change me'
    let myConstant = 'change me' // err: nah
    var myConstant = 'change me' // err: I said nah
    const myConstant = 'sudo change me' // err: fuck off
    myConstant = 'change me' // err: butwhy.gif
    Do you see how it’s useful? If I want to stop a variable from being reassigned, for it to be a constant, read-only value, I now have a way to declare such a thing.
  2. The linters shouldn’t have to save you from yourself. And no, I don’t have time to talk about TypeScript, either. If you want an immutable object, just program an immutable object???
  3. null
  4. You’ve seriously confused the idea that const not communicating what you think it means with it not communicating anything, well, congratulations that you’ve never entered a gigantic, new-to-me codebase and tried to assign a variable with a name that needed to be constant and gotten an err that it was reserved to avoid dangerous side effects. Congratulations that you never worked in a gigantic, new-to-me javascript codebase B.C. (before const) and experienced a side effect of reassigning a variable by accident that needed to remain constant and breaking everything. 
    The idea that anyone, let alone a group of intelligent, experienced software engineers would create something that did not set out to solve a problem is absolutely absurd.
    The problem is not const here. The problem is you, and your attitude.
  5. const I_ACTUALLY_GIVE_A_SHIT_IF_THIS_CHANGES = '42' You’ve decided that using SNAKE_CASE communicates a constant better than const does, but like, that’s just your opinion, man. Not everyone is familiar with this form of constant, where as, the term const does seem to imply it’s a constant. The difference in your comparison isn’t about let vs const, that’s just poor variable naming (at least it is in this context). It has nothing to do with the function of let vs const at all. In this case, though, the only variable declaration that protects your program is const. Naming collisions happen, sometimes even when you try your best to make your variable names as clear as possible. How do you enforce SNAKE_CASE for constants?
  6. If you want some good rules to follow, here’s my best attempt:
    1. Use const when you want a variable to be read-only, and you don’t want it to be reassigned.
    2. Use let when you plan to reassign or change said variable.
    3. Use var when you want your variable to be hoisted. (Never is a good option)
    4. Use Object.freeze() when you want to make an object immutable.
    5. If you want to change ECMAScript, and you think the community is on board, try doing so constructively, and be open to the fact that you’re, uh, wrong.

My dogs are cute:

Maddy & Izzie