Skip to content

Instantly share code, notes, and snippets.

@MatrixFrog
Created May 7, 2012 18:08
Show Gist options
  • Save MatrixFrog/2629373 to your computer and use it in GitHub Desktop.
Save MatrixFrog/2629373 to your computer and use it in GitHub Desktop.
Weirdness with @this
/**
* @constructor
*/
function SomeConstructor() {
}
SomeConstructor.prototype = {
/**
* This one triggers the error.
*/
someMethod: function() {
this.foo = bar;
},
};
(function() {
/**
* @constructor
*/
function SomeOtherConstructor() {
}
SomeOtherConstructor.prototype = {
/**
* This one doesn't trigger the error.
*/
someMethod: function() {
this.foo = bar;
},
};
})();
foo(function() {
/**
* @constructor
*/
function TheThirdConstructor() {
}
TheThirdConstructor.prototype = {
/**
* This one doesn't trigger the error.
*/
someMethod: function() {
this.foo = bar;
},
};
});
@danbeam
Copy link

danbeam commented May 7, 2012

I assume you meant

13: (function() {

and

26: }());

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment