Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Wednesday, March 27, 2013

prototype members should be methods

You want the members of prototype objects to be methods. Adding objects which itself contain methods doesn't sound like a good pattern. – Šime Vidas http://stackoverflow.com/questions/8693279/javascript-accessing-parent-properties-from-inside-nested-function

Tuesday, March 26, 2013

JSON.stringifying a Circular Reference

You can use the replacer function approach to blacklist member names (in contrast to how the replacer argument as an array whitelists member names). I’ve found this approach to be useful when I need quick and targeted logging of certain values from a DOM element, but I want to prevent a serialization exception due to attempting to serialize a circular reference (which would occur if I drank some antifreeze and attempted to do something ridiculous like JSON.stringify(document.body)). 
http://freshbrewedcode.com/jimcowart/2013/01/29/what-you-might-not-know-about-json-stringify/