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:11:12
JULIE GREEN MINISTRIES
2 hours agoLIVE WITH JULIE
48K103 -
LIVE
The Bubba Army
23 hours agoJoe Biden Stumbles on The View - Bubba the Love Sponge® Show | 5/09/25
10,564 watching -
27:56
Coin Stories with Natalie Brunell
18 hours agoMichael Saylor: 100x Return Strategy, Bitcoin vs Macro Panic & the BTC Corporate Treasury Revolution
13.9K3 -
14:44
Adam Does Movies
15 hours ago $3.01 earnedAnother Simple Favor Movie Review
25.6K2 -
18:57
Ohio State Football and Recruiting at Buckeye Huddle
13 hours agoOhio State Football: The Top 5 Most Exciting Buckeyes to Watch in 2025
18.5K3 -
19:48
Melonie Mac
17 hours agoNew Tomb Raider Announcement
27.9K20 -
24:49
JasminLaine
16 hours agoTrump Got The DEAL & Carney Got PUBLICLY EMBARRASSED—and No One Can Defend This
21.2K27 -
14:44
IsaacButterfield
1 day ago $1.27 earnedTRANS TIKTOK STAR DYLAN MULVANEY THE MOVIE!!
27.1K29 -
4:08
The Shannon Joy Show
13 hours ago🔥 Trump’s Pick Sparks MASSIVE Medical Freedom Clash!
20.6K3 -
30:12
The Lou Holtz Show
15 hours agoThe Lou Holtz Show S2 EP9 | Chad Robichaux on Faith, Service & Rescuing 17,000 People #podcast
26.5K2