ga-wdi-exercises / pixart_js

Use JS events and programmatically generated DOM elements to build a drawing application. [javascript, dom]
MIT License
9 stars 321 forks source link

Brendan mahoney solution #129

Closed BMahoney08 closed 8 years ago

BMahoney08 commented 8 years ago

Comfort 3/5 Completeness 5/5

Any help explaining how to use "this" is appreciated. Thank you!

RobertAKARobin commented 8 years ago

Just remember that this is always equal to the object that "owns" the function you called. So if you have:

var cat = {
  name: "Whiskers",
  meow: function(){
    console.log("Meow. I'm " + this.name);
  }
}

...and you call:

cat.meow();

...any this inside the meow function will be equal to cat.