Andrew's Digital Garden

Statements vs Declarations

The terms 'statement' and 'declaration' are often used interchangeably. However in [[js]], they have a precise formal meaning which relates to where it can be used in code.

Statements 'carry out actions'. Declarations 'bind identifiers to values'.

Note that import (and export) are declarations, which means (technically) there's no such thing as an 'import statement'.

There are also expressions. Expressions produce a value. When it comes to [[react]], only expressions can be placed inside braces.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements#difference_between_statements_and_declarations

Statements vs Declarations