Advertisement
Guest User

Untitled

a guest
May 4th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. function Organization(name) {
  2. this.name = name;
  3. }
  4.  
  5. Organization.prototype.greet = function() {
  6. return 'Hello We are ' + this.name + '!!';
  7. }
  8.  
  9. function Company(name) {
  10. Organization.call(this, name);
  11. }
  12.  
  13. Company.prototype = Object.create(Organization.prototype);
  14. Company.prototype.constructor = Company;
  15.  
  16. var bizreach = new Company('engineers');
  17.  
  18. console.log(bizreach instanceof Company); // true
  19. console.log(bizreach instanceof Organization); // true
  20. console.log(bizreach.greet());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement