Skip to content

Instantly share code, notes, and snippets.

@AndreMikulec
Created September 7, 2011 06:04
Show Gist options
  • Save AndreMikulec/1199891 to your computer and use it in GitHub Desktop.
Save AndreMikulec/1199891 to your computer and use it in GitHub Desktop.
<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