News for hackers. Stuff that matters.
Re:Immutable JavaScript data structures, backwards-compatibl... by vjeux on Monday November 03, 2014 @07:19PM (#8554459)
You can define a setter that throws in order to throw without using 'use strict;'. However, additions will still be silent :(

https://gist.github.com/vjeux/6b390e6a6bb51e24b646

    __DEV__ = true;
    var array = ['a', 'b', 'c']
    deepFreezeAndThrowOnMutationInDev(array)
    array[0] = 10;
    Error: You attempted to set the key `0` with the value `10` on an object that is meant to be immutable and has been frozen.

There are no comments on this comment yet.