this.getElement = function(row,col){ return this.matrix[4*row+col]; }; ↓ this.getElement = function(self,row,col){ return self[4*row+col]; };