What is JavaScript

JavaScript is used for web programming to enhance or add to the user
experience when using a web page. This section looks at some of the
aspects of JavaScript that will help you understand the language and give
you a good foundation upon which you’ll be able to really make your web
pages stand out.

JavaScript isn’t Java

Don’t be confused by the name. JavaScript has absolutely nothing to do
with Java — the coffee or the programming language. JavaScript’s name
came about because marketing folks wanted to latch onto the “cool” factor
back when the Java programming language was shiny and new.
Java is a heavy language that doesn’t necessarily run on everyone’s computer;
people have to install extra software to get it to run. Although powerful,
Java is not meant for the types of web programming that you usually need
to do. JavaScript, on the other hand, is included with just about every web
browser and doesn’t need anything else installed. You use JavaScript to
make the pages come alive, with auto-populating form fields, and all kinds of
bells and whistles that enhance the user experience.

One of the most common things that we hear from nontechnical folks is
confusing or calling JavaScript, “Java.” Now that you know that the two are
completely different, you won’t do the same! You will, however, need to
resist the urge to correct people when you hear them confuse the two
languages.
JavaScript is defined by the specification known as ECMA-262. Web browsers
have varying degrees of support for the ECMA-262 specification, so the exact
version of JavaScript that’s available in the browser varies according to the
version of the browser being used.

Knowing what JavaScript can do

JavaScript is an integral part of web pages today. When you see something
like Google Maps, where you can scroll left and right by simply dragging the
map, that’s JavaScript behind the scenes. When you go to a site to look up
flight details, and the site automatically suggests airports as you type into
the field, that’s JavaScript. Countless widgets and usability enhancements
that you take for granted when you use the web are actually JavaScript
programs.


Adding the JavaScript tag

You add JavaScript to a page with the <script> tag, like this:
<script type=”text/javascript”>
// JavaScript goes here
</script>