Articles → JavaScript → Classes In Javascript
Classes In Javascript
How To Create A Class?
<script>
class Person {
constructor() { }
messageme() {
alert("Hi Gyan");
}
}
class PersonWithParam {
constructor(message) {
this.message = message;
}
messageme() {
alert("hello " + this.message);
}
}
person = new Person();
person.messageme();
personWithParam = new PersonWithParam("Gyan");
personWithParam.messageme();
</script>
Try It
Output
Posted By - | Karan Gupta |
|
Posted On - | Saturday, May 2, 2020 |