Reputation: 371
When teaching, it helps to have a common set of terms to describe categories of things to facilitate comprehension. Before let and const, I could just call var, "the var keyword"...
Now we have 3 keywords that are used to declare a variable: var, let and const.
I've done a few searches and still can't find an answer: Is there a categorical name to describe these three keywords separately from any other?
Thanks all!
Upvotes: 4
Views: 316
Reputation: 141827
They are each the first token of a declaration statement, so you could call them "declaration keywords".
However, it's worth noting that let
is not actually a keyword at all. EG.
var let = 5;
console.log( let );
is perfectly valid outside strict-mode, but since const
and var
are keywords, these are not allowed:
var const = 5;
var var = 5;
Upvotes: 5