Hacker News new | ask | show | jobs
by Touche 3896 days ago

   var a = 1;
   a = 2;

   window.someGlobal = 'foo';
3 comments

    const a = {b: "foo"};
    a.b = "bar";
Yea, const provides immutability with respect to assignment, but without immutable objects and collections, it isn't going to get you all the way.

    const a = icepick.freeze({b: "foo"});
Granted, that's not as elegant as built-in support but that is literally what I'm doing at the moment when I want immutability.
So if you go to extraordinary lengths you can use JavaScript functionally but it's not very functional by default aside from the first-class functions. Personally I just embrace it's imperative/functional blended nature and go with it.
Microsoft ruined C# by adding var. var is not your friend. Dynamic typing is not your friend and static languages pretending to be dynamic is akin to evil.
Implicit typing is not dynamic typing, or even "pretending to be dynamic". It's also, I think, off topic - as the example seemed to be talking about mutability in JS, with no C# for miles.
A functional language can allow mutations (see Haskell, LISP, etc.).

All a functional language really needs is first class functions. JS has had that since the very beginning.