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();
-
LIVE
Wendy Bell Radio
5 hours agoYou Realize We Voted For This.
7,233 watching -
26:00
Neil McCoy-Ward
3 hours agoAnd So It Begins… ('Carbon' Food Quotas Are HERE)
3.21K2 -
1:09:24
Chad Prather
16 hours agoWe Must Obey God: The Gospel That Cannot Be Silenced
66.1K20 -
LIVE
The Mike Schwartz Show
1 hour agoTHE MIKE SCHWARTZ SHOW with DR. MICHAEL J SCHWARTZ 11-25-2025
3,333 watching -
LIVE
LFA TV
12 hours agoLIVE & BREAKING NEWS! | TUESDAY 11/25/25
3,000 watching -
4:50
Captain Peach
6 days ago $7.18 earned5 Ways Game Trailers Lie
52.6K2 -
18:06
We Got Receipts
19 hours agoLatest EBT Meltdowns That Are Actually Funny!
27.4K26 -
42:00
Based Campwith Simone and Malcolm
4 days agoNYT Brands Divorce as the Cool New Trend for Gen Z Girls
31.5K7 -
11:43
VSOGunChannel
21 hours ago $3.96 earnedThe Gun Control the Trump Admin is Fighting For
23.7K17 -
1:03:30
A Cigar Hustlers Podcast Every Day
1 day agoEpisode 416 Epstein Files w/Matt Booth
31.3K