The Power of Javascript: Basic Concepts
(Page 1 of 6 )
The best way to learn any programming language is by practice. Javascript is not an exception to this rule, so we will introduce a lot of code in the articles of this series. In this article, you will be introduced to the very basic concepts of the Javascript language. We discuss comments, keywords, identifiers, statements and the semicolon, case sensitivity and white spaces. Note that our examples at this time are limited and we will focus more on the concepts, but after a few articles we are going to discuss many examples on each concept.
To make the concepts easier for you to grasp we will have only one example for this article to explain the concepts we need to discuss. So let's take a look at our simple example.
The Example
This example is very simple, it adds two numbers and writes the total to the Web page. Let's take a look at the code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Hello World</title>
<script language="JavaScript" type="text/javascript">
// This script is used to explain the concepts of
/* Comments, Keywords, Identifiers,
Case Sensitivity, Whitespaces and statements*/
// the firstValue is a location in memory that
// stores the value 10
var firstValue = 10;
var secondValue = 23; // the secondValue is another location in memory that stores the value 23
// result is a location in memory that
// stores the total value of adding firstValue and secondValue
var result = firstValue + secondValue;
// the next line writes some text to the web page
document.write("The total of adding firstValue and secondValue = ");
// the next line writes the value of the result memory location
document.write(result);
</script>
</head>
<body>
</body>
</html>
Save the file and load it into your browser. You will get only one line written to the Web page:

This code example contains everything we need to explain for this article, so let's begin.
Next: Javascript Comments >>
More JavaScript Articles
More By Michael Youssef