Back to Course

Introduction to JavaScript

0% Complete
0/0 Steps
  1. JavaScript: Basics
    9Topics
    |
    10 Quizzes
  2. JavaScript: Variables
    9Topics
    |
    10 Quizzes
  3. JavaScript: Conditional Statements
    10Topics
    |
    11 Quizzes
  4. JavaScript: Functions
    10Topics
    |
    11 Quizzes
  5. JavaScript: Scope
    6Topics
    |
    7 Quizzes
  6. JavaScript: Arrays
    11Topics
    |
    12 Quizzes
  7. JavaScript: Loops
    8Topics
    |
    9 Quizzes
  8. JavaScript: High Order Functions
    3Topics
    |
    3 Quizzes
Lesson 2, Topic 9
In Progress

JavaScript: typeof Operator

Yasin Cakal 30 Oct 2021
Lesson Progress
0% Complete

It’s helpful to keep track of the data types of the variables in your program while writing code. The typeof operator can be used to determine the data type of a variable’s value.

The typeof operator examines the value to its right and returns the name of data type.

const unknown1 = false; 
console.log(typeof unknown1); // Output: boolean 

const unknown2 = 'CodeOfCode';
console.log(typeof unknown2); // Output: string

const unknown3 = 78;
console.log(typeof unknown3); // Output: number
 

Let’s take a closer look at the first example. Because unknown1‘s value is a boolean, typeof unknown1 returns boolean.

Responses

Leave a Reply

%d bloggers like this: