Visit complete TypeScript roadmap
TypeScript Topic

typeof Operator

typeof Operator

The typeof operator is used to check the type of a variable. It returns a string value representing the type of the variable.

let value: string | number = 'hello';

if (typeof value === 'string') {
  console.log('value is a string');
} else {
  console.log('value is a number');
}

Learn more from the following links:

More Topics

Explore related content

View All Topics
Loved by 100K+ Developers

Start Your Learning
Journey Today

Join thousands of developers who are leveling up their skills with structured roadmaps and expert guidance

No credit card required
Always free
Track your progress