News for hackers. Stuff that matters.
Re:An Object is not a Hash by hakaaak on Tuesday October 09, 2012 @12:12AM (#4629922)
Other than lists which can be represented by JSON arrays, hashes do fine jobs at describing most data and most "objects".

This post goes off the rails almost immediately with "Normally this would work fine, but let’s consider that the user could pick any of the keys that are present in any JavaScript object as a name." WTF? The author almost immediately is confusing his/her current situation with the request body and what's in it.

Then we find ourselves quizzically with "We therefore change our code to leverage hasOwnProperty". Umm, I don't think most developers would find themselves "therefore" doing this.

Re:An Object is not a Hash by alanh on Tuesday October 09, 2012 @12:54AM (#4630025)
I think you are missing something.

If I understood the article’s example, he’s suggesting the (perfectly plausible) use case of a new blog post named, e.g., `hasOwnProperty`. Then they would want to set a key named `hasOwnProperty` in the `posts` object, but `hasOwnProperty` is already defined (via inheritance, since all objects have it) as a function (well, native code)… so now you have either (a) prevented your blog from allowing a reasonable blog post title, or (b) seriously mucked up your blog by accepting a blog post title that has the side effect of redefining a basic object method.

The author is not confused.