JavaScript has a list of reserved identifiers. You cannot use these words for your identifiers - click on image to expand
An identifier must start with a letter, a dollar sign, or an underscore. After the first character, you may use letters, numbers, underscores, or dollar signs.
Can you find the error?
A literal is a value that you directly represent in your program - as opposed to a variable.
Use whitespaces to format your code and improve readability.
vsWhitespaces are ignored in JavaScript.
For single line, everything after //
is ignored. In multi line, everything between /*
and */
is ignored.
Can you find the error?
JavaScript uses a semicolon to separate statements.
If you forget a semicolon, JavaScript will try to add a semicolon for you. This can be very dangerous. Always finish your statements with a semicolon.
Code output?
For the return keyword, the break keyword, the continue keyword, and the throw keyword, a line break will be interpreted as a semicolon.
Take x=7 for the following comparisons.
Operator | Description | Comparing | Returns |
---|---|---|---|
=== | equal value/type | x === 7 | true |
!== | not eq value or type | x !== 7 | false |
> | greater than | x > 7 | false |
< | less than | x < 7 | false |
>= | greater or equal | x >= 7 | true |
<= | less or equal | x <= 7 | true |
Take x=7 and y=5 for the following comparisons.
Operator | Description | Comparing | Returns |
---|---|---|---|
&& | and | (x < 10 && y > 1) | true |
|| | or | (x === 7 || y === 7) | true |
! | not | !(x === 7) | false |
click on zip image above