Skip to content
Akin C edited this page Apr 15, 2018 · 16 revisions

Welcome to the Javascript-semicolon-second-rule- wiki!

This repository is part of a larger project!

◀️ PREVIOUS PROJECT| NEXT 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:

  1. When a following character cannot be parsed

Chracters

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.

Keywords

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"!

Content

The user interaction part should look like the content as seen below by starting "index.html" in a web browser.

ERROR: No image found!

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.

Clone this wiki locally