4 ms·
I just can't like javascript, and it's the design idea behind stuff like this that causes it: > Object.freeze(square); > square.length = 20 20 > squ
by RyanZAG 14y ago
I just can't like javascript, and it's the design idea behind stuff like this that causes it:
> Object.freeze(square);
> square.length = 20
20
> square.length
10
square.length = 20 should be throwing an error. No excuses, sane defaults.
- quarterto 14y agoIt throws an error in strict mode. "use strict"; var square = {length:10}; Object.freeze(square); square.length = 20; C:\Users\Matt\Code\seal.js:5 square.length = 20; ^ TypeError: Cannot assign to read only property 'length' of #<Object> at Object.<anonymous> (C:\Users\Matt\Code\seal.js:5:15) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9)