I tried the following code in the Chrome console
var a = new Array(1,2,3,4); a.length
This shows the length as 4 as expected. Now I tried setting the length property as writable: false
Object.defineProperty(a, "length", {writable: false}); a[4] = 5; a.length
The result is 5, even if the property is set to write: false. How did this happen? Should it stay the same as it is read-only (writable: false)?
source share