Trusted answers to developer questions

Javascript typeof

Get Started With Machine Learning

Learn the fundamentals of Machine Learning with this free course. Future-proof your career by adding ML skills to your toolkit — or prepare to land a job in AI or Data Science.

The typeof operator in Javascript returns the data type of the operand in the form of a string.​

svg viewer

Syntax

Look at the syntax of the typeof operator below.

svg viewer

Code

The code snippet below illustrates the usage of the typeof operator.

console.log(typeof 19);
console.log(typeof 'Educative');
console.log(typeof false);
// a variable declared but not initialized or defined
var x;
console.log(typeof x);

RELATED TAGS

typeof
javascript
datatype
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?