How come in the code below, the second line is giving me an undefined error?
function DAO()
{
this.arrVariable = new Array();
this.getItem = getItem;
this.getItemQuery = getItemQuery;
}
function getItem(key)
{
dao.arrVariable[key]();
}
function getItemQuery(key, url, options, pollfrequency)
{
alert('hey');
}
var dao = new DAO();
dao.arrVariable['var1'] = function() { this.getItemQuery('a','b','c','d'); };
dao.arrVariable['var1']();
I want to be able to access the dao's getItemQuery as an object call. How do I do this?
function() {this.getItemQuery}dao.addVariableis declared as an array, do you really intend to add the object propertyvar1to it? In JavaScript, syntax likearrVariable['var1']refers to an object property, not an array key.x = {}; x["key1"] = "A";