Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.