Jump to content

Losing Scope when passing between functions.


jjwallace
 Share

Recommended Posts

var Fish = function (game, superThis, index, x, y, size, angle, pSize) {

//Bunch of code

console.log('FISHSIZE 1: ' + pSize);
this.pSize = pSize;
this.setSize(this.pSize);

}

Fish.prototype.constructor = Fish;

Fish.prototype.setSize = function(pSize){
    console.log('FISHSIZE 2: ' + pSize);
    
}

FISHSIZE 1: 0. 2

FISHSIZE 2: undefined

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...