JavaScript basics

Objectives

JavaScript comments

There are two types of JavaScript comments. Single line comments start with a double slash (//) and everything after that on the line is treated as a comment. Single line comments automatically end at the end of the line. Multiline comments start with a slash star (/*) and end with a star slash (*/). Multiline comments may start and end on the same line or span several lines. Multiline comments can NOT be nested.

See W3schools.com JavaScript comments article

  1. examples of single line comments:
    //  May be the only thing on a line
    var color; // may follow some JavaScript code
  2. examples of multiline comment:
    /*
        Detailed explanations of sections of code
        are often multiline comments
    */

JavaScript object terminology

Indentation

JavaScript doesn't care about indentation. In fact, once a library of JavaScript code is stable, it is common to minimize the code to make it load faster. One of the many ways code is minimized is by getting rid of indentation. Indentation does serve an important purpose before that point. Indentation makes code more readable and maintainable by setting off blocks of connected code from other code surrounding it. There are many styles that programmers use, but it is important to indent the body of a function, the branches of an if or if/else statement, and the body of a loop.

Strict mode