Skip to main content
5 events
when toggle format what by license comment
Dec 16, 2021 at 18:45 comment added Flimm I completely agree with @Sethen . Please don't monkey-patch globals implemented by the browser like this. It can break code and it's not future-compatible with browsers that may ship a setObject method in this global in the future.
Jul 6, 2014 at 18:54 comment added Sethen Just my two cents, but I'm pretty sure it's not a good idea to extend objects provided by the vendor like this.
Oct 8, 2012 at 10:45 comment added PointedEars This getObject() will throw a SyntaxError exception if the stored value is "", because JSON.parse() cannot handle that. See my edit to Guria's answer for details.
Dec 9, 2010 at 1:28 comment added Garrett Wrapping CMS' approach up into a function is a good idea, it just needs a feature tests: One for JSON.stringify, one for JSON.parse, and one to test if localStorage can in fact set and retrieve an object. Modifying host objects is not a good idea; I would rather see this as a separate method and not as localStorage.setObject.
Jan 6, 2010 at 4:42 history answered Justin Voskuhl CC BY-SA 2.5