Exforsys.com
 
Home Tutorials JavaScript
 

JavaScript Introduction

 

JavaScript Introduction

In this JavaScript tutorial, you will learn about introduction to JavaScript, why JavaScript, differences between Java and JavaScript and advantages of JavaScript.



What is JavaScript?

JavaScript was first developed by Netscape as an open scripting language to create interactive web pages. Script is nothing but a small program which is generally very easy to learn and use. JavaScript as an open language implies that it can be used by anyone; no license is required to use JavaScript. Microsoft created Jscript for its Internet Explorer similar to Netscape JavaScript. JavaScript has the ability to function both as an object oriented language as well as procedural language. Using JavaScript you can create objects, attach methods and properties. Though JavaScript can run on both client-side and server-side, it is very popular among client-side scripting languages. Client side means the script runs on client browser. JavaScript are generally embedded in the header of web pages.


Why JavaScript?

JavaScript plays a vital role for adding interactive feature to HTML web pages. JavaScript can respond to several events that occur on web-pages and thereby help in designing dynamic and interactive web-sites. Moreover JavaScript makes it very easier to validate a form, check if any fields are empty and verify correctness of data. JavaScript does all these at client side even before actually sending the data to server, thereby reducing considerable load on server and thus makes form processing easier and quicker. Millions of web-pages and server applications make use of JavaScript all over the world, there is no doubt that almost all major web-browsers support JavaScript.


My First JavaScript

JavaScript Example


<HTML>
<HEAD>
   <TITLE>My First JavaScript</TITLE>
</HEAD>
<BODY>
   <H1 ALIGN=CENTER>
   <BR /><BR /><BR />
   <SCRIPT LANGUAGE="JavaScript">
   document.write("My First JavaScript")
   </SCRIPT>
   </H1>
</BODY>
</HTML>


Output



JavaScript can be used in different ways within an HTML file.


1. header scripts
In this type, JavaScript is embedded between <SCRIPT> tags within the <HEAD> tag and is used for initializing variables and or create functions that can be called from anywhere of the entire script. JavaScript in header is executed once when the page is loaded.


2. body scripts
In this type, JavaScript is embedded between <SCRIPT> tags within the <BODY> tag. JavaScript within Body Tags are used for handling various events.


3. called directly when certain events occur
In this type, JavaScript are called when certain events occur. Example of events include onLoad, onClick, onError, onSelect, onSubmit, onChange etc.,


Differences between Java and JavaScript:

JavaScript is different from Java programming language, Unlike Java, which needs compilation; JavaScript is dynamic and is interpreted in run-time. Though there are some similarities like both Java and JavaScript are client-side programming language, both descend from C++ yet both Java and JavaScript differ in many ways.


  • Java was developed by Sun Microsystems while JavaScript was developed by Netscape.
    .
  • JavaScript is a high-level scripting language whereas Java is an Object Oriented Programming language.
    .
  • JavaScript is easy to learn and use whereas Java is comparatively difficult.
    .
  • In case of Java programming language the code is first written and then compiled. In JavaScript the script can be executed without any compilation.
    .
  • JavaScript as conveyed can be directly embedded or placed in HTML but it is not possible in case of Java. One cannot write Java code directly into HTML. .

JavaScript was mainly developed for web pages or web sites to add interactive facility or feature and there by making programming effort easier, enable users to interact with web sites and there by making it user-friendly. In addition to interactive facility JavaScript also helps in giving a dynamic functionality for a webpage which helps JavaScript to handle large volume of data during online processing.



Advantages of JavaScript:

JavaScript offers numerous features which makes it popular. Few among them are listed below:


  • JavaScript is a dynamic open scripting language with simple syntax and rules which makes it easier to use and learn for programmers. This has made JavaScript a popular Client-side scripting language.
    .
  • It is an interpreted language meaning that it could be used or executed with ease without pre-compilation.
    .
  • JavaScript is very useful for creating interactive web pages or web sites.
    .
  • JavaScript helps in adding dynamic functionality to websites
    .
  • JavaScript makes it very easier to validate a form at the client side without connecting to server. JavaScript has the ability to instantly notify users in case there is any mistake in input data.

Read Next: JavaScript Features



 

 

Comments


mohammad khan said:

  I just want to say thanks for providing all great tutorial to help everyone at web world.
April 5, 2007, 10:18 pm

Sharath Bhat said:

  Hi Guys,
Just want to share a link which can really help on any of the queries related to Javascript and DHTML. Refer to the MSDN link:
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/reference/dhtml_reference_entry.asp?frame=true
For any element of HTML you can see what all things can be supported, including events. This can be called as a Bible for people who want to refer.

Cheers,
Sharath
April 12, 2007, 12:25 am

sheetal said:

  its good tutorial to provide us a great information about different languages
May 21, 2007, 9:40 am

Hassan Parkar said:

  Its a great thing to make peaple study online and get a good knowledge for there future betterment.
Excellent!!
Thanks n regards
June 3, 2007, 11:24 pm

Mohammed Irshad said:

  Hello this is Irshad from Hyderabad..
i was searching for all these notes at the net and i was struggling alot to download all the notes at my disk..!
but now i felt all that i need is at my disk...!
i really thankfull to www.exforsys.com to providing all these notes to me...!
July 2, 2007, 5:07 am

Manisha_karegaonkar said:

  Hiiiiiii,
This site is very nice.
It has a abundunt source of knowledge and information.
Its really awersome..
Many people will get answers of all their queries at only one place and that is
WWW.EXFORSYS.COM
August 1, 2007, 6:52 am

Sunil singh said:

  Hello
This is very good for online learing.You r doin a great job.Excellent Keep it up...
Thanks...
August 16, 2007, 1:32 pm

kiranmaye said:

  Your r doing an excellent job for online learning.thanks.keep it up..........
October 18, 2007, 12:51 pm

BImal said:

  This tutorial is very good.......
November 26, 2007, 12:13 am

renuka shinde said:

  www.exforsys.com is a woderful for all the beginers who want to learn more about programming u get lots of information through this site.thank you exforsys.


January 10, 2008, 5:46 am

ahmed ali khan yousufzai said:

  This tutorial is veryyyy good
September 6, 2008, 12:40 am

0 said:

  Hi,
This site is very very important for knowledge seeker,I really appreciate & thanks those people who first made plan to lounch such types of nice web site.

I hope they will keep on in future & will provide latest technologies skills to us.


With Regards
Komal
January 15, 2009, 3:14 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape