Skip to content

Instantly share code, notes, and snippets.

@AkashRajvanshi
Created November 2, 2019 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkashRajvanshi/d9276499159241454ce3506b24dd6e82 to your computer and use it in GitHub Desktop.
Save AkashRajvanshi/d9276499159241454ce3506b24dd6e82 to your computer and use it in GitHub Desktop.
function User(firstName, lastName, age) {
this.firstName = firstName,
this.lastName = lastName,
this.age = age
}
const Akash = new User('Akash', 'Rajvanshi', 22);
User.prototype.toString = function getDetails() {
return `I am ${this.firstName} ${this.lastName} (${this.age})`
}
console.log(Akash.toString()) // I am Akash Rajvanshi (22)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment