I recently encountered an problem where I am not creating an array correctly for objects.
So I tried to do the following thing in javascript:
function Mesh()
{
this.buffer = [10, 10, 10];
}
Mesh.prototype.getBuffer = function ()
{
return this.buffer;
};
function main()
{
var model = new Mesh();
var modelBuffer = model.getBuffer;
document.getElementById("textSection").innerHTML = modelBuffer[0];
}
I'm trying to avoid using global variable hence I've created the array the way I did in my Mesh() constructor. But when I try to retrieve the data from slot 0 it prints "undefined". How do I get this work? I really have no idea why this is happening...