I got a definition that looks like so:
function className(data)
{
this.dataRecords = [];
$.each(data, function(key, item)
{
this.dataRecords.push(new dataRecord(item.record));
}
}
But for some reason js does not think this.dataRecords is actually an array. I modified the code to do the following:
function className(data)
{
var array = [];
$.each(data, function(key, item)
{
array.push(new dataRecord(item.record));
}
this.dataRecords = array;
}
This works fine, but i'd rather push the data to the actual object, in stead of now having to do another this.dataRecords = array; to get the job done. I want to give the class functions for manipulating this.dataRecords from my class's perspective( like addRecord and removeRecord), which with this technique, becomes a little tedious.
Is there any way I can make js recognize the array(this.dataRecords) as an array?