+ 7
const person = {
name: 'John Doe',
age: 30
};
+ 3
function Person(name, age) {
this.name = name;
this.age = age;
}
Person.prototype.introduce = function() {
console.log(`Hello, my name is ${this.name} and I am ${this.age} years old.`);
};
// Creating an instance
const person1 = new Person("John Doe", 30);
person1.introduce(); // Output: Hello, my name is John Doe and I am 30 years old.
+ 1
let information = {
name: 'Name You Want',
age:12
};
Note: Name must be on ' ' or " " ,becuase its string and name can be int or string no problem.