White spaces are the spaces, tabs and line breaks that you use to improve your code readability. We could write the script in the example as follows:
var firstValue = 10;var secondValue = 23;var result = firstValue + secondValue; document.write("The total of adding firstValue and secondValue = ");document.write(result);
We have written three statements in first line and two statements in the second line. If you saved the code like this it will be executed in the same way. So white spaces are used to make your code look better and organized. You can't use white spaces inside an identifier, so you can't write the identifiers in our example as follows:
Replace the <script> block of the Web page with the above one and save the page. When you load it into IE and Firefox you will get the following error messages, respectively:
These error messages tell us that the interpreter expects a semicolon after the first, because it considers it an identifier for a variable.
When you save this file and load it into your browser, you will get the following Error Messages in IE 6 and Firefox 1.3:
Actually, there is a problem that you will encounter while you are programming, which is the casing style you use for your identifiers. There are two casing conventions used among programmers, Pascal casing and camel casing. Pascal casing states that all the words in your identifier begin with a capital letter, and there's no character that separates the words. For example, the identifiers FirstValue, SecondValue, and Result all display valid Pascal casing.
Camel casing states that the first word of your Identifier begins with a small letter, the following words in the Identifier begin with a capital letter, and there are no characters that separate the words. We will use the camel casing for variable identifiers; we will talk about variables and data types in detail in the next article.
So the example contains comments, keywords, identifiers and statements (plus other things which we don't need to know now). It simply declares two memory locations, stores some values there, then add them, puts the result in a third variable, and writes it to the Web page. I will take you step-by-step through the various examples in thsi article series, so you won't find any difficulties.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.