DEV Community

Cover image for Reference: JavaScript Expressions, Keywords, Statements, Syntax & Operators
Michael Scott Hertzberg
Michael Scott Hertzberg

Posted on • Edited on

Reference: JavaScript Expressions, Keywords, Statements, Syntax & Operators

Primary Expressions

Basic keywords and general expressions in JavaScript take the highest precedence, even that of operators.

Literals

  • null
  • true or false (Boolean)
  • 1234 (Number or BigInt for larger integers)
  • string (Template literal syntax, using backticks)

Keywords

Special

  • this
  • super

Regular Expression

  • /regex/

Initializers

  • []
  • {}

Operators

  • () (Grouping)
  • ?. (Optional chaining)
  • new
  • , (Comma allows multiple expression evaluation, returning the result of the last expression)

Increment & Decrement

  • A++
  • A--
  • ++A
  • --A

Unary

  • delete
  • void
  • typeof
  • +
  • -
  • ~
  • !
  • await

Arithmetic

  • ** (Exponentiation)
  • *
  • /
  • %
  • +
  • -

Relational

  • <
  • >
  • <=
  • >=
  • instanceof
  • in

Equality

  • ==
  • !=
  • ===
  • !==

Bitwise shift

  • <<
  • >>
  • >>>

Binary bitwise

  • &
  • |
  • ^

Binary logical

  • &&
  • ||
  • ??

Conditional (Ternary)

  • (condition ? ifTrue : ifFalse)

Assignment

Destructuring assignment - JavaScript | MDN

  • =
  • *=
  • /=
  • %=
  • -=
  • <<=
  • >>=
  • >>>=
  • &=
  • ^=
  • |=
  • **=
  • &&=
  • ||=
  • ??=

Yield

  • yield
  • yield*

Notation

=> (arrow functions)

Numbers

  • Decimal literals can start with 0 followed by another decimal digit. If all digits after the leading 0 are smaller than 8, the number is interpreted as an octal. To define octal values, use the prefix 0o (e.g., 0o71), similar to 0x for hexadecimal and 0b for binary.
  • BigInt literals cannot start with 0 to avoid confusion with legacy octal literals.
  • Octal literals always use 0o, followed by digits (e.g., 0o777). For octal BigInts, use 0o followed by digits and n (e.g., 0o123n).

Statements & Declarations

Statements

  • break
  • continue
  • debugger
  • do...while
  • for
  • for await...of
  • for...in
  • for...of
  • if...else
  • someLabel:
  • return
  • switch
  • throw
  • try...catch
  • var
  • while

Declarations

  • export
  • function
  • function*
  • async function
  • async function*
  • class
  • const
  • let

Syntax

Other

Top comments (0)