alankis

Inheritance -JS pseudo-classical

Oct 17th, 2013
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Foo(name){
  2.     this.name = name;
  3. };
  4.  
  5. Foo.prototype.getName = function() {
  6.     console.log("Name is " + this.name);
  7. };
  8.  
  9. var myFoo = new Foo('MyFoo');
  10.  
  11. // myFoo.getName();
  12.  
  13. function Bar(name) {
  14.     this.name = name;
  15. };
  16.  
  17. Bar.prototype = inherit(Foo.prototype);
  18.  
  19. var myBar = new Bar('MyBar');
  20.  
  21. myBar.getName();
Advertisement
Add Comment
Please, Sign In to add comment