-
Notifications
You must be signed in to change notification settings - Fork 0
/
classJS.js
44 lines (41 loc) · 853 Bytes
/
classJS.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/**
* Can you create Employee Payroll Data
with id, name and
salary
Create all methods and functions also
getter setter and constructor should also be there
*/
class Employee{
id;
name;
salary;
constructor (id,name,salary){
this.id = id
this.name = name
this.salary = salary
}
set setId( id){
id = this.id
}
get getId(){
return this.id
}
set setName(name){
name = this.name
}
get getName(){
return this.name
}
set setSalary(salary){
salary = this.salary
}
get getSalary(){
return this.salary
}
}
let worker1 = new Employee(1,"Veer",10000)
let worker2 = new Employee(2,"Priya",15000)
console.log(worker1)
console.log(worker2)
worker1.setName = "Viru"
console.log(worker1)