---
title: "JavaScript typeof operator"
url: https://weworkworldwide.com/tutorials/javascript-typeof-operator-3/
description: "In this section we will learn what the typeof operator is and how to use it in JavaScript. What is typeof operator in JavaScript? (JavaScript Check Type )"
date: 2026-07-29T17:00:05+00:00
source: https://weworkworldwide.com/llms.txt
---

# JavaScript typeof operator

In this section we will learn what the typeof operator is and how to use it in JavaScript.

## What is typeof operator in JavaScript? (JavaScript Check Type )

Sometimes we need to know the current type of the value that is stored in a variable.

This is where we can use the `typeof` operator.

We put the name of the variable on the right side of this operator and it will return us the type of the value that is stored in that variable.

## How to use typeof operator in JavaScript? (typeof operator syntax)

This is how we can use the typeof operator in JavaScript:

``` line-numbers
Typeof variableName;
typeof value;
```

## Example: using typeof operator in JavaScript

``` line-numbers
<!DOCTYPE html>
<html>
<head>
<title>JS is fun :)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script>
const num = 10;
const big = 234234234232354n;
const str = "This is a String value";
const obj = {};
const symbol = Symbol();
const bool = true;
console.log(typeof num);
console.log(typeof big);
console.log(typeof str);
console.log(typeof obj);
console.log(typeof symbol);
console.log(typeof bool);
</script>
</body>
</html>
```

Note that, calling a variable will actually return a copy of its value and so here the `typeof` operator in fact is checking the value that is stored in each variable.

## Example: applying typeof operator on String in JavaScript

``` line-numbers
<!DOCTYPE html>
<html>
<head>
<title>JS is fun :)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script>
console.log(typeof true);
console.log(typeof 33n);
console.log(typeof “test”);
</script>
</body>
</html>
```

We can also store the returned value of the `typeof` operator in a variable.

## Example: typeof operator in JavaScript

``` line-numbers
<!DOCTYPE html>
<html>
<head>
<title>JS is fun :)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script>
let num = typeof 10;
let str = typeof num;
console.log(num);
console.log(str);
</script>
</body>
</html>
Output:
number
string
```

As you can see, in the first statement, the `typeof 10;` returned `number` as the type of the value `10`. But in the second statement `typeof num;`, the returned value is `string`.

## Example: applying typeof operator on Object in JavaScript

``` line-numbers
<!DOCTYPE html>
<html>
<head>
<title>JS is fun :)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script>
const obj = {
name: "John",
lastName: "Doe"
}
console.log(typeof obj);
</script>
</body>
</html>
Output:
object
```
