Javascript typeof

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);
Copyright ©2024 Educative, Inc. All rights reserved