Skip to content

Instantly share code, notes, and snippets.

@kikar
Last active March 11, 2016 10:51
Show Gist options
  • Save kikar/b9affe87f4f6f9769643 to your computer and use it in GitHub Desktop.
Save kikar/b9affe87f4f6f9769643 to your computer and use it in GitHub Desktop.
Not this
function foo(num) {
console.log( "foo: " + num );
this.count++;
}
foo.count = 0;
foo(1); // foo: 1
foo(5); // foo: 5
foo(10); // foo: 10
console.log('Wrong: ', foo.count ); // Wrong: 0
console.log('Right: ', count); // Right: NaN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment