Premium Only Content

Learn JavaScript STATIC keyword in 8 minutes! ⚡
// static = keyword that defines properties or methods that belong
// to a class itself rather than the objects created
// from that class (class owns anything static, not the objects)
// ----------- EXAMPLE 1 -----------
class MathUtil{
static PI = 3.14159;
static getDiameter(radius){
return radius * 2;
}
static getCircumference(radius){
return 2 * this.PI * radius;
}
static getArea(radius){
return this.PI * radius * radius;
}
}
console.log(MathUtil.PI);
console.log(MathUtil.getDiameter(10));
console.log(MathUtil.getCircumference(10));
console.log(MathUtil.getArea(10));
// ----------- EXAMPLE 2 -----------
class User{
static userCount = 0;
constructor(username){
this.username = username;
User.userCount++;
}
static getUserCount(){
console.log(`There are ${User.userCount} users online`);
}
sayHello(){
console.log(`Hello, my username is ${this.username}`);
}
}
const user1 = new User("Spongebob");
const user2 = new User("Patrick");
const user3 = new User("Sandy");
user1.sayHello();
user2.sayHello();
user3.sayHello();
User.getUserCount();
-
28:54
Producer Michael
14 hours agoANSWERING YOUR MOST IMPORTANT QUESTIONS!
7.63K2 -
8:24
Hollywood Exposed
13 hours agoCNN Host Turns on Democrats LIVE And Bill Maher Can’t Believe It!
3.34K9 -
30:59
Uncommon Sense In Current Times
17 hours ago $0.45 earnedImmigration, Crime & Justice Reform | Brett Tolman on Borders, Cartels & the First Step Act
10.4K1 -
15:36
The Gun Collective
13 hours agoWOW! Tons of NEW GUNS just dropped!
4.23K10 -
LIVE
BEK TV
23 hours agoTrent Loos in the Morning - 10/08/2025
147 watching -
2:21
NAG Daily
12 hours agoPOLITICAL FAMILY GAMESHOW w/ GreenMan Reports
4.07K -
0:49
OfficialJadenWilliams
16 hours agoGTA 6 is downloading but you hear trumpets outside
4.29K4 -
1:02:11
DeVory Darkins
15 hours ago $41.70 earnedDemocrats suffers ANNIHILATION during heated hearing with Bondi as Jack Smith bombshell drops
171K133 -
57:17
Dialogue works
2 days ago $3.36 earnedAmb. Chas Freeman: Israel on the EDGE: Is TOTAL DEFEAT IMMINENT?!
39.4K21 -
14:06
Actual Justice Warrior
1 day agoSomali Medicaid SCAMMER Says Theft Is HIS CULTURE
20.4K26