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.
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.
// 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>
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.