Skip to content

Commit 5bb1744

Browse files
authored
Create 9.1StaticMethodAndProperty.js
1 parent af2d35c commit 5bb1744

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

OOPS/9.1StaticMethodAndProperty.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
class student{
2+
static id=1; //STATIC PROPERTIES
3+
constructor(name,age,marks){
4+
this.name=name;
5+
this.age=age;
6+
this.marks=marks;
7+
this.id=student.id++;
8+
}
9+
10+
//STATIC METHODS
11+
static sort_age(s1,s2){
12+
return s1.age-s2.age;
13+
}
14+
static sort_marks(s1,s2){
15+
return s1.marks-s2.marks;
16+
}
17+
}
18+
const a=new student('rakesh',20,89);
19+
const b=new student('shyama',21,96);
20+
const c=new student('raju',19,85);
21+
const stu=[a,b,c];
22+
// stu.sort(student.sort_age);
23+
stu.sort(student.sort_marks);
24+
console.log(stu);

0 commit comments

Comments
 (0)