Advertisement
AyanUpadhaya

Basic object oriented programming in JS

Oct 30th, 2021
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Employee = function(firstName,lastName,age){
  2.   this.firstName = firstName;
  3.   this.lastName = lastName;
  4.   this.age = age;
  5. };
  6.  
  7. Employee.prototype.getFullName= function(){
  8.   console.log(this.firstName+" "+this.lastName);
  9.  
  10. };
  11.  
  12. const person = new Employee("Ayan","Upadhaya",28);
  13.  
  14. console.log(person.age);
  15. person.getFullName();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement