Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to use window.hasOwnProperty() in Internet Explorer?

I have a method, that perfectly works in Firefox, with which I can determine the name of an instance of a particular javascript object (please don't ask why I need it...). Fr example:

var temp = new String("hello!");
var theName = getVarName(temp); //returns "temp"

This method uses "window.hasOwnProperty()" which doen't work in Internet Explorer: any suggestions?

like image 205
Enrico Murru Avatar asked Nov 27 '22 02:11

Enrico Murru


1 Answers

If for whatever reason you do need to use window, use:

Object.prototype.hasOwnProperty.call(obj, p)
like image 181
Lawrence Pit Avatar answered Dec 04 '22 06:12

Lawrence Pit