create object class js code example
Example 1: javascript classes
class SayHelloTo {
name (to) {
console.log(`Hello ${to}`);
}
constructor (to) {
this.name(to);
}
}
const helloWorld = new SayHelloTo(World);
Example 2: js create object with properties
function Car(make, model, year) {
this.make = make;
this.model = model;
this.year = year;
}