Classes in javascript
In this article, we are creating a class
1class human {
2constructor(name) {
3this.name = name;
4}
5describe() {
6return Person named ${this.name};
7 }
8}
9
10class Employee extends human {
11constructor(name, title) {
12super(name);
13this.title = title;
14}
15describe() {
16 return super.describe() +(title:, ${this.title});
17 }
18}
19const jane = new Employee('Jane', 'CTO');
20jane.describe() //Person named Jane,title: CTO
Here we have created class named 'human' with one property 'name' and one method 'describe'. Extended another class 'Employee' from 'human' class.
About
Moiz is a software engineer from Arid University with a passion for writing tech tutorials and doing coding. I am continously produce JavaScript and other web development technology tutorials in concepts through easy-to-understand explanations written in plain English.I have expertise in next js ,react js ,javascript,html,bootstrap and node js.
Follow him on TwitterHassan is a software engineer from kohat university of science and technology with a passion for writing tech tutorials and doing javascript practices on daily basis.I have expertise in next js ,react js ,javascript,html,bootstrap and node js. Problem Solving and making concpets is my strong point.
Follow him on TwitterTags
Click to see all tutorials tagged with: