alankis

Pseudo-classical OOP pattern

Oct 17th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Animal(name) {
  2.     this.name = name;
  3.     this.canWalk = true;
  4. }
  5.  
  6. Animal.prototype.sit = function() {
  7.  
  8.         this.canWalk = false;
  9.         alert(this.name + ' sits down.');
  10.     };
  11.  
  12.  
  13. var animal = new Animal('Pet');
  14. console.log(animal.canWalk);
  15. animal.sit();
  16. console.log(animal.canWalk);
Advertisement
Add Comment
Please, Sign In to add comment