Skip to content
This repository was archived by the owner on Feb 29, 2024. It is now read-only.
This repository was archived by the owner on Feb 29, 2024. It is now read-only.

Guard against object with own property "hasOwnProperty" #51

@Krinkle

Description

@Krinkle

From timotijhof on September 25, 2011 18:19:11

Although it's a fairly rare edge case, suppose an object looks like this:

var FooBar = {
isAwesome: true,
getProp: function(){ },
hasOwnProperty: true
};

Then the check that fixed issue 50 in r38 will fail since it would use the own property "hasOwnProperty" instead of the Object.prototype.hasOwnProperty function.

Fix by using Object.prototype.hasOwnProperty.call( foobar, key );
instead of foobar.hasOwnProperty( key ); which depends on the fact that the objet itself will never have a property by that name.

Original issue: http://code.google.com/p/jquery-json/issues/detail?id=51

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions