Skip to content

Comment on Structs and ImmutableStructs

Comments

One way to make an immutable constant:

    function rentAmountDollars() {
      return 600;
    }

rentAmountDollars = function() { return 601; }

This will work with pass-by-value primitives, but not pass-by-reference objects unless the getter re-creates the object for every get action.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.