Advertisement
eimkasp

Basic class example javascript

Aug 2nd, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. // Sukuriame zmogaus klase
  3. var Person = function(name, surname) {
  4.     this.name = name;
  5.     this.surname = surname;
  6.     this.isGangsta = true;
  7. };
  8.  
  9. Person.prototype.kill = function(victim) {
  10.   if (this.canTalk) {
  11.     console.log('Hi, I am ' + this.name);
  12.     console.log('Die, ' + victim.name);
  13.   }
  14. };
  15.  
  16.  
  17.  
  18.  
  19.  
  20. var tom = new Person("Tom", "Smith");
  21. var john = new Person("John", "Bravo");
  22.  
  23. if(tom.isGangsta) {
  24.     tom.kill(john);
  25. }
  26.  
  27. tom.name;
  28. tom.kill();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement