News for hackers. Stuff that matters.
Re:An Object is not a Hash by mun2mun on Tuesday October 09, 2012 @01:55AM (#4630185)
I think this problem can be easily solved by encapsulating access/creation methods of posts objects in a object say postStore where posts variable is private property and the object have savePost(slug) and getPost(slug) methods where access/creation methods are defined by yourself. If posts object is that much mission critical than it should not be exposed to outer world.
Re:An Object is not a Hash by kansface on Tuesday October 09, 2012 @02:53AM (#4630323)
Instead of writing code around the problem, its better to just use a safe reference (ie, use Underscore's has method which will call Object.prototype.hasOwnProperty). This way code stays both simple and safe.