-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This repository is part of a larger project!
This project contains the second rule of semicolons in Javascript. The other ones are found here:
Javascript inserts internally semicolons, according to second rule:
- When a following character cannot be parsed
Nevertheless there are five characters which can be troublesome and should be used mindful. These are
Character | Name |
---|---|
"(" | Paranthesis |
"[" | Square bracket |
"+" | Plus |
"-" | Minus |
"/" | Slash |
It is recommended to keep an eye to the next line following a statement, because it could help to avoid or find an error.
Another awareness should be invested when concatenating js files. With concatenating files it is meant that for example the content of two files are merged into one.
A newline directly after some specific keywords could cause unwanted results. These keywords are:
Keyword | Example | Description |
---|---|---|
"return" |
return
a;
|
No parse error, but does not return the value of a! |
"throw" |
throw
"ERROR!";
|
Parse Error |
"break" |
Label_one:
for(var i = 0; i < 4; ++i)
{
Label_two:
for(var j = 0; j < 2; ++j)
{
//ATTENTION
break
Label_one;
}
}
|
No parse Error, but does not break Label_one! |
"continue" |
Label_one:
for(var i = 0; i < 4; ++i)
{
Label_two:
for(var j = 0; j < 2; ++j)
{
//ATTENTION
continue
Label_one;
}
}
|
No parse Error, but does not continue Label_one! |
For deeper insight, please execute the projects "index.html" and analyse "rule.js"!
The user interaction part should look like the content as seen below by starting "index.html" in a web browser.
To use the project just download the files and execute "index.html". Note that all files should be placed in the same folder so that the functionality of the code is guaranteed.
This knowledge was gained:
-
Effective JavaScript "68 Specific Ways to Harness the Power of JavaScript" by David Herman
-
Github markdown, syntax highlight of code blocks in the table cell asked by Ziav and answered by Pokechu22