Search
Left Quote    Every day I get up and look through the Forbes list of the richest people in America. If I
- Robert Orben    
Right Quote
 
[login] | [Register]
 

Learning JavaScript Basics

by: bs0d
Page: 1 of 10
(View All)

Background

Before we get started I would like to just inform you a bit on the background of JavaScript. In 1995, JavaScript was developed by Netscape Communications Corp (The same company who build the Netscape Navigator). At first, was referred to as LiveScript. Netscape decided to change its name to JavaScript because of its relationship with Java.

Also, JavaScript does not require any special software or tools to execute. In fact, all you're going to need to get started coding is notepad and a browser. Even if you use a browser like Opera or Mozilla FireFox, they will recognize JavaScript in web documents.

The definition of JavaScript is: A scripting language that has the ability to combine HTML and other elements from a programming language all in one package. So JavaScript is as flexible as PHP. In PHP, you can simply jump in and out of HTML. This is pretty much the same with JavaScript. You will see exactly what I mean once you read on through the tutorial.

Once you begin coding in JavaScript this will always be your first line:



This first line of code is going to tell your browser that you will be using JavaScript. Once you have finished coding your document, you will use the following line of code that will tell the browser that you're done using JavaScript at that time.



*All statements in JavaScript will be between the <Script> and </script> tags. Also, all statements in JavaScript must end with a semi-colon (;).

Pretty simple? Programmers say that JavaScript is one of the easiest languages to learn, and it is a great starting point for aspiring programmers. Another reason it is a good place to start is because the JavaScript syntax is quite similar to C. So once you have learned JavaScript, learning C will be much easier.

EXTERNAL LINKING



Now if you're going to use JavaScript in your html document, and you do not want it all cluttered up, then the is a way to hold the javascript in a separate file, and link to it. This would save some space in your html document and could also keep you on track. The following code below indicates the way to link to your external javascript document:




As you can see from the example above, your external javascript documents will need the ".js" extension. So if you decide to create your JavaScript outside of your html document, remember to save your script with a ".js" extension.

*Also just a little extra information, your external JavaScript file does not need to include the <script> and </script> tags

COMMENTS



In every programming language, you can add in comments with your program. Comments are lines of code that will not be executed with the rest of the program. It is wise to indicate comments because It can help you remember what you're doing yourself if the project is quite big. Also, it can be helpful for others that may see your program. This can help them learn to code themselves.

Now, there are several different ways to use comments in JavaScript. JavaScript recognizes single line comments, and multiple line comments. If you were to insert a comment that would only span one line, you will use the double slash: //.

example:


To enter multiple line comments, or comments that are going to take up more that one line (like a paragraph) you will use the /* and the */ characters.
example:



Now that we've covered that, lets go ahead and move on to Variables and Constants.


1  |  2  |  3  |  4  |  5  |  6  |  7  |  8  |  9  |  10  |  
Next »


Comments:

  vinayg
  Subject: "goodwork" Date: Jul 01 2007 at 1:52 am    
An excellent tuorial for a beginner to learn all the basics of a java script.It really helped me .
You Must be logged in or a member to comment.


Tutorial Stats

Tutorial Stats

368,115 Views
3 Total Comments
4.66 Rating of 5 (3 Votes)

Options

Tutorial Options

· Login to Rate This Article
· Login to Post a Comment
· Read more by this author
Digg This Article! Del.icio.us: Bookmark This Article Reddit: Bookmark This Article BlinkList: Blink This Article! YahooMyWeb BlogMarks: Add This Mark! Furl: Save This Article Spurl: Mark This Article

Articles

Related    

· Getting Started with Ajax
Your Article Here


"AllSyntax.com" Copyright © 2002-2014; All rights lefted, all lefts righted.
Privacy Policy  |  Internet Rank