graduate Posted November 24, 2011 Share Posted November 24, 2011 Hello, It is my first message on this forum and I'm currently learning JavaScript. When I try this code var a = [1,2,3];Object.defineProperty(a, 'length', {value:10, writable:false}); I get an error from Firebug - "defining the length property on an array is not currently supported". I've read in the fresh 6th edition of "Java Script" book of David Flanagan that I can make a length property of an array unwritable with Object.defineProperty method, but I get the same error from Firebug when I try to apply this method a to change any property (value, writable etc.). Link to comment Share on other sites More sharing options...
Ingolme Posted November 24, 2011 Share Posted November 24, 2011 You can't modify the length property of an array. It doesn't make logical sense. If an array has 5 elements and you set the length to 3, you've messed up the whole structure. Link to comment Share on other sites More sharing options...
graduate Posted November 24, 2011 Author Share Posted November 24, 2011 No, I can change the length property of an array, but I can't apply Object.defineProperty to it. Link to comment Share on other sites More sharing options...
Ingolme Posted November 24, 2011 Share Posted November 24, 2011 Hmm, the length property is writeable...If Firefox tells you it's not supported yet, then there really isn't anything you can do about it. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.