Old question old; but still completely appropriate. I also searched for a quick answer to this question, and eventually figured out what a good solution before I read this, so I decided to share it.
Object.defineProperty("hasOwnPropertyCI", { "enumerable": false, "value": function(keyName) { return (Object.keys(this).map(function(v){ return v.toUpperCase() }).indexOf(keyName.toUpperCase()) > -1) } });
This enables true when keyName exists in the object it calls:
var MyObject = { "foo": "bar" }; MyObject.hasOwnPropertyCI("foo");
Hope this helps someone else !: D
PS: Personally, my implementation throws the conditional expression above into the IF statement, since I will not use it anywhere else in my application (in addition to the fact that I am not a huge fan of manipulating native prototypes).
source share