Introduction to JavaScript

Before learning JavaScript you should have basic knowledge of HTML and CSS, be able to use a HTML editor such as Notepad and
an Internet browser such as Mozilla Firefox.

JavaScript and Java are two different languages. Java is a full programming language, more powerful (but more complex) and it
must be compiled before a program can be executed. JavaScript is a scripting language which doesn’t need a compiler, it is simpler,
and more indulgent in some areas, such as syntax.

JavaScript has similarities to other programming/scripting languages such as Java, C++, C, Perl etc and having experience in one
of these languages (although it is not required) it will help you learn JavaScript much easier.

JavaScript was released in 1995 and version 1.0 became available with Netscape Navigator 2.0.

JavaScript is an object based scripting language which means it can use items that are called objects.

JavaScript is a client-side scripting language which means that JavaScript runs in the Web browser a viewer uses.

JavaScript code is added directly to the HTML document, either directly (placed between script tags) or by linking to
an external JavaScript file.

Although JavaScript is set as default in most browsers (if not all) it is a good idea to specify which scripting language is
being used.

As I mentioned above, JavaScript can be placed in an external file which is saved with .js file extension and it
contains just JavaScript code. It is called by adding a src attribute to the script tag.

As in other languages, in JavaScript you can use comments, so you can for example describe what a line of code does.
A JavaScript comment can be used to disable a line of code that is believed to create errors.
A pair of forward slashes // mark the beginning of a single line of comment.
The code placed before the slashes will be executed by the browser; only the code after the slashes will be considered a comment.

To add comments that span on multiple lines you have to use a forward slash followed by an asterisk at the beginning of the
comment and an asterisk followed by a forward slash at the end of the comment.

document.write("This text is written with JavaScript."); // This is just a comment

/* Comments are not displaied by the browsers
Comments are used for describing what code does
This is a multiple-line comment
Below I placed the slashes in front of the code
so the code will not be executed by the browser */

// document.write("This text is written with JavaScript.");

Leave a Reply