function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype.getDetails = function() {
return this.name + ' is ' + this.age + ' years old.';
};
const john = new Person('John', 25);
console.log(john.getDetails());Ответ:
John is 25 years old
JavaScript test | #JavaScript