top of page

JavaScript Tokens: Basic building blocks

Writer: compnomicscompnomics

In JavaScript, tokens are the basic building blocks of the code that the interpreter understands and processes. These tokens are categorized into different types based on their function and meaning. Here's a list of the main JavaScript tokens:







Reserved Keywords:

These words have special meanings within the language and cannot be used as variable names or identifiers. Examples include varletconstifelseforwhilefunctionreturn, etc.


Identifiers:

These are names given to variables, functions, classes, and other entities you define in your code. They must start with a letter or underscore (_), followed by letters, numbers, or underscores.


Literals:

These represent fixed values directly embedded in your code. Examples include:

  • Numbers: 1234.56-100e2

  • Strings: "Hello, world!"'This is a string'${variableName} (template literals)

  • Booleans: truefalse

  • Null: null

  • Undefined: undefined


Operators:

These perform various operations on values. Examples include:

  • Arithmetic: +, -, *, /, %

  • Comparison: ==!====!==, <, >

  • Logical: &&||!

  • Bitwise: &, |, ^, <<>>

  • Assignment: =+=-=*=, etc.


Punctuators:

These are special characters used for syntax and structure. Examples include:

  • Brackets: []{}()

  • Commas: ,

  • Semicolons: ;

  • Quotes: '"

  • Dots: ... (spread operator)

  • Arrows: -> (function definition)


Whitespace:

Spaces, tabs, and newlines are generally ignored by the interpreter but can be used for readability.


Comments:

Comments are lines of text ignored by the interpreter but used to explain your code and improve its clarity. They start with // for single-line comments or /* ... */ for multi-line comments.

Remember that this is a basic overview, and the specific list of tokens might vary depending on the JavaScript version and specific context.

Comentarios

Obtuvo 0 de 5 estrellas.
Aún no hay calificaciones

Agrega una calificación
bottom of page