Questions: JavaScript Grammar
Questions prerequisites:
A statement is a unitary piece of code that denotes a single logical task in a program.
It's often less precisely said that a statement in JavaScript is any instruction terminated by a semicolon (;
). There isn't any necessity for a statement in JavaScript to be terminated by a semicolon, and hence we refrain from defining it this way. Learn more in JavaScript Grammar: What are statements?
False. In JavaScript, a block statement, denoted via curly braces ({}
), serves to contain multiple statements within it.
An expression is a piece of code that gets resolved down to a value. Learn more in JavaScript Grammar: What are expressions?
True. For example, the expression 5 + (3 + 5)
is comprised to two simpler expressions: 5
and (3 + 5)
(which is itself comprised of two expressions: 3
and 5
). Learn more in JavaScript Grammar: What are expressions?
A primary expression is the simplest expression in JavaScript; it doesn't contain any other expression within it. Some examples of primary expressions are: 1
, 'Hello'
, true
, undefined
, null
, and so on. Learn more in JavaScript Grammar: Primary Expressions.
A keyword is a special word that denotes a particular operation. An example is var
, which is used to define a new variable in JavaScript. Learn more in JavaScript Grammar: What are keywords?
No we can't. That's simply because typeof
is a keyword and it's invalid to name a variable the same as a keyword in JavaScript.
Yes we can. Even though typeof
is a keyword in JavaScript, TYPEOF
has a different case (i.e. it's in all caps) and thus is distinct from typeof
.
An operator is a symbol or a keyword that denotes a special operation to be carried out on a given value or a set of values. Learn more in JavaScript Grammar: What are operators?
The three categories are as follows:
- Unary operators, involving just one operand. An example is
typeof
. - Binary operators, involving two operands. An example is
+
. - Ternary operators, involving three operands. An example is
?:
.
Learn more in JavaScript Grammar: What are operators?
ASI, or Automatic Semicolon Insertion, is a feature of JavaScript whereby semicolons (;
) are automatically inserted where there is a need to. Learn more in JavaScript Grammar: Semicolons and ASI.
Spread the word
Think that the content was awesome? Share it with your friends!
Join the community
Can't understand something related to the content? Get help from the community.