Created
July 21, 2017 22:38
-
-
Save raullucero/679b3a69dca6bc7994342de4a4cc1c0c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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