Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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