Javascript Models
A JavaScript model is an object that represents a data structure in a JavaScript application. It is a way to store and organize data and associated logic, and can be used to manage and manipulate the data in an application.
class User {
constructor(name, age) {
this.name = name;
this.age = age;
}
sayHi() {
console.log(`Hi, my name is ${this.name} and I am ${this.age} years old.`);
}
}
const user = new User('John', 30);
user.sayHi();
In this example, we have defined a User model with two properties name and age, and a method sayHi that outputs a greeting message.