zero_shubham1

inherince_not_really_inheritance

Aug 21st, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //A prototype similar to the concept of class
  3. var Person = function(name, age, gender){
  4.     this.name = name;
  5.     this.age = age;
  6.     this.gender = gender;
  7.  
  8.     this.detailsDisplay = function(){
  9.         console.log(this.name);
  10.         console.log(this.age);
  11.         console.log(this.gender);
  12.     };
  13. };
  14.  
  15. var Career = function(job, experience, salary){
  16.     this.job = job;
  17.     this.experience = experience;
  18.     this.salary = salary;
  19.  
  20.     this.detailsDisplay = function(){
  21.         console.log(this.job);
  22.         console.log(this.experience);
  23.         console.log(this.salary);
  24.     };
  25. };
  26.  
  27. var john = new Person('John', 90, 'Male');
  28. john.Career = new Career('DJ', '10', '500');
  29. john.detailsDisplay();
  30. john.Career.detailsDisplay();
Add Comment
Please, Sign In to add comment