Created
September 7, 2011 06:04
-
-
Save AndreMikulec/1199891 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
<html> | |
<body> | |
<script type="text/javascript" | |
src="http://yui.yahooapis.com/3.4.0/build/yui/yui-min.js"></script> | |
<script> | |
YUI().use('oop', function(Y) { | |
function Person(){ this.name = "Adam";} | |
Person.prototype.getName = function() { | |
return this.name; | |
} | |
function Programmer() { | |
// Need to get 'Adam' (guru.name) | |
Programmer.superclass.constructor.apply(this, arguments); | |
this.nickname = "Abel"; | |
} | |
Y.extend(Programmer, Person); | |
Programmer.prototype.getName = function(){ | |
// returns 'undefined' (Why is that?) + 'Abel' | |
return Programmer.superclass.getName() + ' ' + this.nickname ; | |
} | |
var guru = new Programmer(); | |
alert(guru.getName()); // undefined Abel | |
alert(guru.name); // Adam | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment