Skip to content

Instantly share code, notes, and snippets.

@raullucero
Created July 21, 2017 22:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raullucero/679b3a69dca6bc7994342de4a4cc1c0c to your computer and use it in GitHub Desktop.
Save raullucero/679b3a69dca6bc7994342de4a4cc1c0c to your computer and use it in GitHub Desktop.
// Problem
var Foo = function (a) {
function baz () {
return a;
}
this.bar = function () {
return a;
}
};
Foo.prototype = {
biz: function () {
return a
}
}
// Cual seria el output
var f = new F(7);
f.baz(); // Exception
f.bar(); // 7
f.biz(); // a undefined
//Que harias para que funcionara
var Foo = function (a) {
this.a = a;
this.baz = function () {
return this.a;
}
this.bar = function () {
return this.a;
}
};
Foo.prototype = {
biz: function () {
return this.a
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment