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();
-
1:01:55
VINCE
3 hours agoIs This Why They Were Hiding The Evidence? | Episode 192 - 12/19/25 VINCE
170K111 -
LIVE
Badlands Media
7 hours agoBadlands Daily: 12/19/25
3,370 watching -
14:45
Bearing
3 hours agoFROGAN Gets BODIED 💥 Caleb Hammer, Asmongold + the $20k Rejection 💰
10.7K11 -
1:10:23
Graham Allen
3 hours agoTensions ERUPT At AMFEST, Is Our Party Too Far Gone?
118K533 -
LIVE
Caleb Hammer
2 hours agoThis Has Never Happened Before | Financial Audit
269 watching -
LIVE
The Big Mig™
3 hours agoTrump Drops Bombshell: Weed Reclassified to Schedule III
2,687 watching -
23:17
The Car Edition Ltd
8 hours ago $0.69 earnedFord Fiesta 1.4 Titanium Full Overhaul | Suspension, Brakes, Tyres & Engine Repair - The Car Edition
12.4K -
LIVE
Wendy Bell Radio
7 hours agoHouston, We Have A Problem
5,898 watching -
1:06:37
Chad Prather
18 hours agoHearing God, Confronting Deception, and Walking in Spirit-Filled Authority
90.8K22 -
2:20:42
Game On!
20 hours ago $5.90 earnedNFL Week 16 BEST BETS Revealed NOW!
56K7