Tokens in JavaScript

RMAG news

So, keeping it simple.

Tokens are the smallest elements of the programs that are meaningful to js inerpreter, during the parsing of the script to an Abstract Syntax Tree.

Tokens includes all:-

Keywords(let, int, for, while, etc.)
Identifiers(variables, operators(+, -, *, /), etc.)
Punctuators((), {}, [], comma(,), semicolon(;), dot(.) , etc)
Comments(//, /* */)

Here’s an analogical example

Let’s say you have a blueprint(Abstract Syntax Tree) that guides that the placement and arrangements of the bricks(keywords, variables, operators, punctuators, comments) of different shapes and sizes to create a structure of the building(program).