What is JavaScript and What is not

JavaScript is a programming language intended to be used to make HTML content dynamic, this characteristic has made JavaScript the most popular programming language. The JavaScript code is executed in our web browser like Chrome, Internet Explorer, Firefox, and Safari.

JavaScript is not Java though the names of both programming languages sound very similar these are two different programming languages created for different purposes.

JavaScript vs JavaScript

To be able to create some JavaScript code you will need to use a text editor, some good text editors are Notepad++, or Sublime.

JavaScript Sentences

A program in JavaScript is composed of “sentences”, when we talk about sentences in JavaScript we refer to a line of code that contains instructions for the computer to execute. Eeach sentence is delimited by a ; indicating the end of that sentence.

alert("Welcome to JavaScript");

In this example we are instructing our web browser to display a popup window with the message “This is a sentence”

Comments

Comments: Comments are phrases written in the code to make it possible for developer to document or leave comments about the code. Comments are ignored and are not executed by the browser comments are indicated using the symbols // or /**/

To comment a single line of code we use the // and to comment a block of code or many lines of code we use /**/

                        // This is one line comment
                        /*
                            This is multiple line
                            comment
                        */
                    

Adding JavaScript to a web page

The way to add JavaScript code in an HTML5 web page is accomplished using the tags. There are 3 ways in which JavaScript can be added to a HTML5 page.

  1. Using the <script></script> tags within the tags of the HTML page.
  2. Using <script></script> tags within the <body></body> tags of the HTML page.<
  3. Executing external JavaScript files.