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:02:27 1:02:27VINCE2 hours agoA Very Trump Halloween | Episode 159 - 10/31/25108K39
- 	
				 LIVE LIVEBadlands Media10 hours agoBadlands Daily: October 31, 20254,001 watching
- 	
				 1:34:28 1:34:28Graham Allen3 hours agoSCARY: Kamala Had MELT DOWN Over Trump!! Does LSU Hate Charlie Kirk?! + Top Halloween Movies Of ALL TIME!!73.8K37
- 	
				 LIVE LIVECaleb Hammer1 hour agoShe Blames MAGA For Her Debt | Financial Audit235 watching
- 	
				 LIVE LIVEThe Big Mig™3 hours agoWhat To Give The Man Who Has EVERYTHING!5,142 watching
- 	
				 1:32:16 1:32:16Benny Johnson2 hours agoSHOCK: Massive Food Stamp FRAUD Exposed: 59% of Welfare are Obese Illegal Aliens!? Americans RAGE…22K39
- 	
				 LIVE LIVEWendy Bell Radio7 hours agoAmerica Deserves Better6,196 watching
- 	
				 22:01 22:01DEADBUGsays2 hours agoDEADBUG'S SE7EN DEADLY HALLOWEENS14.6K5
- 	
				 LIVE LIVETotal Horse Channel13 hours ago2025 IRCHA Derby & Horse Show - October 31st41 watching
- 	
				 1:10:29 1:10:29Chad Prather15 hours agoStanding Holy in a Hostile World54.5K29