create html class in javascript code example
Example 1: create element javascript with class
var div = document.createElement('div');
div.className = "div1";
Example 2: javascript create class
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
present = () => {
console.log(`Hi! i'm ${this.name} and i'm ${this.age} years old`)
}
}
let me = new Person("tsuy", 15);
me.present();
Example 3: javascript create class
class Car {
constructor(brand) {
this.carname = brand;
}
}
Example 4: how to create class in javascript
class ClassName
{
}