🚧 施工中
JS ⟩ grammar ⟩ statement vs. declaration
statementsarrow-up-right and declarationsarrow-up-right are two disjoint sets of grammars.
the following are (9) declarations:
letarrow-up-right, constarrow-up-right
let
const
functionarrow-up-right, function*arrow-up-right
function
function*
async functionarrow-up-right, async function*arrow-up-right
async function
async function*
classarrow-up-right
class
exportarrow-up-right, importarrow-up-right (can only appear at the top-level of a modulearrow-up-right)
export
import
everything else in this listarrow-up-right is a statement.
statement vs. declaration
var is a statement❗
let/const is a declaration.
👉 statement expected❗️❗
declaration: binding identifier to value.
statement: carrying out actions.
Difference between statements and declarationsarrow-up-right ⭐️⭐️⭐️ ❗️❗️❗️
ECMA ⟩
Statementarrow-up-right
Declarationarrow-up-right
Last updated 3 years ago