3 ms·
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/6b3
by vjeux 12y ago
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 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.