graduate Posted January 25, 2012 Share Posted January 25, 2012 Object.defineProperty(window, 'num', { value:'655'});var num = 100;alert(window.num); In Firefox the program throws exception "var num is read-only" and the variable isnt changed, but in IE and Chrome it outputs "100", the variable was changed without any errors.How does it work? Link to comment Share on other sites More sharing options...
Ingolme Posted January 25, 2012 Share Posted January 25, 2012 Most likely not all browsers support making read-only variables. Link to comment Share on other sites More sharing options...
justsomeguy Posted January 25, 2012 Share Posted January 25, 2012 In Firefox, properties created using defineProperty default to read-only unless you specify otherwise. Check the documentation for other options: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/defineProperty Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.