0

I'm trying to use Object-Oriented Javascript, following the model shown in the MDN Tutorial here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Introduction_to_Object-Oriented_JavaScript#Prototype-based_programming

So I have my constructor:

// Constructor
var Transmitters = function() {

    this.tdb = new Array();
    this.arrNearbyList = new Array('asfd');

};

Then I try to access it in a member method:

// Load into the member attribute
Transmitters.prototype.parseTransmitters = function(transmitterData) {

    this.tdb = transmitterData;

    this.arrNearbyList.push("test"); 

};

I get TypeError: this.arrNearbyList is undefined. If I try to access this.tdb from another member method it's also undefined, so it's only local in scope to the parseTransmitters method.

I'm pretty sure I followed the way it's shown in the MDN article, I don't understand what I'm doing wrong here.

David Findlay
  • 957
  • 1
  • 9
  • 27

0 Answers0