The Computer Gal Logo - Laptop with coffee and plants
What is JavaScript?
If you would like to receive weekly emails with articles like this one, email Nora

The plan for this class is to spend the first session working through exercises that will introduce you to the the basics of JavaScript and programming principles, and the second session working through a more complicated JavaScript that you can use to validate the user entry of your online forms. Before you begin your work in this class, go to My Documents on your computer and create a folder with your name and the current quarter. You will be saving all your work in this folder.

Programming Exercises

What is JavaScript?
JavaScript is a "client-side" programming language. Client-side means that the program code is sent into your computer with the rest of the web page code (usually HTML); then, your browser reads the code and does what it says. That means that on many sites with JavaScript, you can look at the programming code right along with the HTML by going to Edit -> View Source in your browser. You can usually tell if the code has JavaScript in it because the head tag will have a like that says script language="JavaScript". That is a good way to look at some working scripts. (Some websites to hide their JavaScript.)

JavaScript can do more than HTML because HTML is static, but JavaScript is dynamic, which meanst that it can react to viewer actions, such as clicking or rolling the mouse over an object. JavaScripts are often called "behaviors." A behavior is made up of a viewer "event" and a response or "action" by the programming. You can program a behavior to happen when a viewer clicks, or you can program it to happen when the viewer double clicks - that is the "event." When the "event" happens, the programming responds by showing something, like a dropdown menu, or by doing something, like playing a sound. With JavaScript, you site is "dynamic" because it responds to your viewer beyond regular hyperlinks!

Newer browsers generally have newer versions of JavaScript, which means there are more programming options. Some old browsers can't read JavaScript, or they can only read limited amounts of JavaScript. A browser that is JavaScript enabled can read some version of JavaScript.

JavaScript doesn't have any thing to do with the Java programming language, even though their names are similar. Click here for a page with a Java program. JavaScript is frequently used to do simple programming tasks because web viewers can turn JavaScript off on their computer, which means that all your hard programming work doesn't function when they view your site. JavaScript may be turned off for security, and there have been browsers that have JavaScript disabled as a default setting. Instead, we use JavaScript to enhance the functionality of a web page. For example, if you completely rely on JavaScript to validate your online forms, you have a security hole. If a viewer's JavaScript is turned off, it will by-pass your validation. So, you may also use a "server-side" programming language to double check the input.

There are other types of scripting that look a lot like JavaScript. For example, the Flash program has its own scripting language called ActionScript, and many of the effects it produces in Flash are similar to what JavaScript can do on a page. For example, you can create a set of rotating images in JavaScript. The same thing can be done in Flash, except the Flash action is generally much smoother. If you learn JavaScript, you have the basics to start on many other scripting languages that are used for web pages.

More Complicated JavaScript

Related Articles

  1. Using a Text Editor and a Browser to Create a Web Page
  2. What is JavaScript?
  3. Using a Pre-defined Function in JavaScript
  4. Variables, Math, Concatenation and Overloaded Operators
  5. Using a Prompt Box and Outputting to the Screen
Nora McDougall-Collins | Missoula, Montana 59801 | 406.253.4045 | info@thecomputergal.com
© 2009, Nora McDougall