Articles → JavaScript → Class Expression In Javascript
Class Expression In Javascript
Class Expressions
Types Of Class Expressions
- Named
- Unnamed
Example
<html><head><title>Class Expression Demo</title><script>
// Named
const myclass1 = class MyClass1 {
message1() {
alert("Myclass1");
}
}
new myclass1().message1();
// Unnamed
const myclass2 = class {
message2() {
alert("Myclass2");
}
}
new myclass2().message2();
</script></head><body></body></html>
Output