Background:

JavaScript data types

There are six different data types in JavaScript:

  • string
  • number
  • boolean
  • object
  • function
  • symbol

There are three object types:

  • Object
  • Date
  • Array

Two data types that do not contain any values:

  • null
  • undefined

The typeof operator

You can use the Typeof operator to see the data types of JavaScript variables.

<! DOCTYPEhtml>
<html>
<head>
<meta charset="utf-8">
<title>Sun Called beast's blog</title>
</head>
<body>

<p>The Typeof operator returns the types of variables, objects, functions, and expressions.</p>
<p id="demo"></p>
<script>
document.getElementById("demo").innerHTML = 
    typeof "john" + "<br>" +
    typeof 3.14 + "<br>" +
    typeof NaN + "<br>" +
    typeof false &
Copy the code