Logo
HTMLCSSJavaScriptReactjsnewContactUpdates

Get started today

HTMLCSSJavaScriptReactjsnewContactUpdates

Tools

Resume BuilderQR GeneratorVS Code Editor

Connect

GitHubWhatsApp Channel
javascript runtime environment
scope

Javascript Tokens

By Saket Bhatnagar•June 14, 2025•Beginner to Intermediate

Table of Contents

  1. token
  2. Operators
  3. Punctuators
  4. keywords
  5. identifiers
  6. literals
  7. Types of literals / Datatypes
  8. Primitive literals
  9. Primitive datatypes
  10. Non-Primitive literals

token

  1. 1It is the smallest unit of programming language.
  2. 2We have 5 types of operators,punctuators,keywords ,identifiers , literals.

Operators

  1. 1These are symbols or words that represent mathematical, logical, or other operations.
  2. 2Examples include : +, -, *, /, =, ==, ===, &&, ||, !, and typeof.

Punctuators

  1. 1These are symbols used to group, separate, or punctuate code.
  2. 2Examples include parentheses (), curly braces {}, square brackets [], commas ,, semicolons ;, and the period . (used to access object properties).

keywords

  1. 1These are reserved words that have a special meaning in the language.
  2. 2Examples like if, else, for, while, function, and return,etc.

identifiers

  1. 1These are user given names to variables, functions, and other objects in the code.
  2. 2Identifier name can not start with number.
  3. 3Identifier name should not be a keyword
  4. 4If Identifier is of multiple word, instead of using space, we have to use underscore.
  5. 5identifier name should not have special character but can start with underscore(_) and dollar($).

literals

  1. 1These are values used in our program like number(2),string('hello world') , etc.

Types of literals / Datatypes

  1. 1Primitive
  2. 2Non-Primitive

Primitive literals

  1. 1In JavaScript, a primitive data type is a data type that represents a single value.
  2. 2JavaScript treats primitive values as immutable values, means that their value cannot be changed. Instead, when you perform an operation that appears to modify a primitive value, you are actually creating a new object with new value and assigning it to a variable. Here , variable will hold the reference of latest object with new value and the previous object with it's value will garbage collected.
  3. 3We have 8 primitive types of literals -number , bigint , boolean , nan , undefined , null , symbol , string..

Primitive datatypes

  1. Number

    • 1This data type represents a numeric value. It can store both integers and floating-point values.
    • 2It's range is from -253-1 to 2 53-1 .
  2. BigInt

    • 1It is used to represent integers that are larger than the Number data type
    • 2It's range is more than -253-1 and more than 253-1 .
    • 3To represent the given integer as bigint , we have to suffix 'n' after the integer.
      Example : 10 is number type and 10n is bigint type.
  3. Boolean

    • 1This datatype represents a logical entity and can only have two values: true or false.
  4. Null

    • 1This datatype represents a null or empty value.
    • 2It is used to mark the memory block empty intentionally.
  5. Undefined

    • 1This datatype represents an uninitialized value.
    • 2When memory block is unintialized , js engine implicitly initialize that memory block with 'undefined' in variable phase.
    • 3For variable declared with 'var' it will initialize it in variable phase
    • 4For variable declared with 'let' and 'const' it will not initialize it in variable phase.
  6. NaN

    • 1It stands for 'not a number'.
    • 2It represents computational error.
    • 3When js engine is not able compute result it returns 'NaN'.
    • 4Example : "Hello" + 1 = Hello1 and "Hello" - 1 = NaN
      In first case , js engine concatnated the string with number.
      In second case , js engine is able to compute anything because we can not subtract 1 from "Hello" string therefore it returns NaN.
  7. Symbol

    • 1It represents a unique identifier.
    • 2We have Symbol function which is used to generate unique idenitifiers in our program.
  8. String

    • 1It represents collection of characters.
    • 2We have two types of strings :- single line and multi line string.
    • 3Single line string :
      - It is enclosed by single quotes (' ') and double quotes (" ") .
      - It doesnot allow line breaks and whitespaces.
    • 4Multi line string :
      - It is enclosed by backticks (` `).
      - It allow line breaks and whitespaces.
      - It is also called as template string.
      - Template strings allow us to insert variables and expressions directly in the string using ` ${ variable_name } ` notation.

Non-Primitive literals

  1. 1In JavaScript, a non primitive data type is a data type that represents multi value.
  2. 2JavaScript treats non-primitive values as mutable values, means that their value can be changed. When we try to update a value , new object is not created . Here value is changed in the same memory block.
  3. 3Non-primitive datatype : object ,array , etc

Share this article

Last updated: July 14, 2025

Join Our Community

Login to Join

© 2025 Saket Bhatnagar. All rights reserved.

    ☕