JavaScript

Introduction

JavaScript is usually used as a client-side scripting language allowing web developpers to improve the functionality and appearance of webpages. It has the ability to generate web page's content dynamically and on the fly when accessed by the user. It's a great language for front-ended development and very flexible but little slow. However Node.js (the server-sdie version of JavaScript) is the answer for backend programmers who are interested in performance.

Let's have a glimpse at a simple JavaScript program that output the text "Hello World!" in an HTML5 document
	<!DOCTTYPE html> 
<!--Example 1: Hello.html -->
<html>
<head>
<title> A simple JavaScript program </title>
<script type = "text/javascript ">
document.writeln(" <h2>Hello World!</h2>");
</script>
</head>
<body></body>
</html>
Here is how it looks on the browser:


JavaScript code is case-sensitive and is usually between the head tags of an HTML5 document. The <script> tag specified to the Web browser that the code written here is a script. Double quote or single quote can be used to contain a string of characters.

Statements end with a semicolon. The write method writes a line of characters in the HTML5 document to be displayed by the browser. The alert method, which can be written without the prefix window displays an alert box with a message in it. The escape sequence \n indicates the new line and the plus sign + indicates joining two strings. A comment line is preceded with a double forward bar "// but multiline comments use delimiers and hence start with the delimiter /* and finish with */.

Keywords in JavaScript have specia meaning and can not be used by the developper for different purpose. For example the keyword var is used to declare variables before they are used, and where each one should have a type and a value. A variable name to be considered as a valid identifier, it can neither be a JavaScript reserved keyword nor start with a digit. Characters to use to declare name variables include digits, dollar signs, letter, and underscore.

Topics Covered:

  1. Assigning a value to a variable and interacting with the user


  2. Mathematical operations


  3. Decision Making


  4. Loops


  5. More examples on Loops


  6. How JavaScript simplies the use of Aritmetics


  7. Multi Selection using the Switch


  8. Break Statement


  9. Continue Statement


For more details, please contact me here.
Date of last modification: 2021