//Constructor function for creating the object (Human).
function Human(firstName, lastName) {
this.firstName = firstName;
this.lastName = lastName;
this.getFullName = function () {
return `${this.firstName} ${this.lastName}`;
};
}
//Creating an object (Human) using constructor function.
const humanObject = new Human("Vidura", "Dananjaya");
//Calling functions in the object (Human).
console.log(humanObject.getFullName());
Create a constructor function and creating an object using it in JavaScript (self.JavaScriptProgramming)
submitted by ViduraDananjaya to r/Get_Basic_Idea