Home arrow JavaScript arrow Page 2 - The Power of Javascript: Basic Concepts
JAVASCRIPT

The Power of Javascript: Basic Concepts


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.

Author Info:
By: Michael Youssef
Rating: 4 stars4 stars4 stars4 stars4 stars / 30
July 05, 2005
TABLE OF CONTENTS:
  1. · The Power of Javascript: Basic Concepts
  2. · Javascript Comments
  3. · Javascript Statements
  4. · Keywords
  5. · Identifiers
  6. · White Spaces and Case Sensitivity

print this article
SEARCH DEVARTICLES

The Power of Javascript: Basic Concepts - Javascript Comments
(Page 2 of 6 )

Comments are descriptive text that is ignored by the interpolator, which we use to comment our scripts. Comments in Javascript take two forms. The first form is a comment that takes one line. You use two forward slashes for it (//) followed by your comment, like the following:

// the firstValue is a location in memory that
// stores the value 10

Note that in this example the comment has spanned two lines, so we needed two forward slashes at the beginning of each line. As you can see, the whole line is used for the comment, but you can put your comment after the Javascript code line, as in the following line:

var secondValue = 23; // the secondValue is another location in memory that stores the value 23

The second form of the comment you can use is the multiple line comment, which you define by using a forward slash followed by an asterisk (/*), and end using an asterisk followed by a forward slash (*/). All of the lines between those symbols are considered a comment, like the following:

/* Comments, Keywords, Identifiers,
Case Sensitivity, White spaces and statements*/

Also, it can be written like this:

/*
Comments, Keywords, Identifiers,
Case Sensitivity, White spaces and statements
*/

At first you may not appreciate the importance of including comments in your scripts, but when you gain enough experience to write complex Javascript, you definitely will need to comment. Imagine that you have written a very important script for your company's website and after one year your manager asked you to modify the functionality of the script to do something else. You will open your script and may ask yourself "Why did I write the script this way?" and find that you don't remember. You may spend many hours trying to understand why and how your wrote the code that way.

To give another possible situation, say you wrote the script and after one year, while you are on vacation, your manager asked your co-programmer to modify this script. He will spend more hours than you to try to understand your code. So for you and for anyone else who might use your code, it's better to include comments in your scripts; that way, when you come back later you understand what's going on. You (or anyone else who needs to modify the code) can just read the scripts and comments and easily do what needs to be done.

However, when you are done with your script, it's better to remove the comments from the Web page (to minimize the page size and thus save bandwidth). You can write your scripts and save them in a Javascript file (with the extension .js), and name it after the Web page or any other name to remind you that this script is written for that page. In this file you can comment your code as much as you want, then you can copy the script (without the comments) into the Web page.


blog comments powered by Disqus
JAVASCRIPT ARTICLES

- Project Nashorn to Make Java, JavaScript Wor...
- JavaScript Virus Attacks Tumblr Blogs
- Google Releases Stable Dart Version, JavaScr...
- Khan Academy Unveils New JavaScript Learning...
- Accessing Nitro? There`s an App for That
- JQuery 2.0 Leaving Older IE Versions Behind
- Fastest JavaScript Engine Might Surprise You
- Microsoft Adjusting Chakra for IE 10
- Brendan Eich: We Don`t Need Google Native Cl...
- An Overview of JavaScript Statements
- An Overview of JavaScript Operators
- Overview of JavaScript Variables
- More of the Top jQuery Social Plugins
- The Top jQuery Social Plugins
- More of the Top jQuery Slider Plugins

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials