var array = []; Array.prototype.indexOf = function (elt) { var len = this.length; var from = Number(arguments[1]) || 0; for (; from < len; from++) { if (from in this && this[from] === elt) return from; } return -1; }; function columInfo(name) { this.Name = name; } array.push(new columInfo("Name")); array.push(new columInfo("ID")); array.push(new columInfo("StartTime")); var name = array[0]; index = array.indexOf(name); console.log(index);
<br/><p><font size="3"><b>Source for this<a target="_blank"href="http://jqfaq.com/how-to-workaround-inarray-issues/"</a> JQFaq Question</b></font></p> <iframe id="iframe1" src="http://jqfaq.com/AdPage.html" style="width:100%;border:none;" />