JavaScript typeof | Find Type of Variable

The typeof operator in JavaScript, is used to find the type of variable/value. For example:

HTML with JavaScript Code
<!DOCTYPE html>

   <p id="para1"></p>
   <p id="para2"></p>
      let x = 10;
      document.getElementById("para1").innerHTML = typeof x;
      document.getElementById("para2").innerHTML = typeof "codescracker";

JavaScript typeof Syntax

The syntax of typeof operator in JavaScript, is:

typeof x

x refers to the variable or value, whose type we need to find.

JavaScript Online Test

« Previous Tutorial Next Tutorial »

Follow/Like Us on Facebook

Subscribe Us on YouTube