Tuesday, March 19, 2024

JavaScript Primers – Introduction

and Andree Growney

Use these to jump around or read it all
Why Now? |
My Co-Author |
How You Will Learn |
Primer Format



Table of Contents

Welcome to the HTML Goodies JavaScript Primers! The purpose of these 30 lessons is to get you started writing your own JavaScript events. If you’ve tried to learn JavaScript through a book or from the Internet, my guess is that you found it quite difficult. Me, too. Learning JavaScript is literally learning a new language. The text may be English, but the construction of the sentences is quite different.




Why Now?

I get e-mail all the time asking, “When are you going to put together a series of primers for writing JavaScript?” Most readers of HTML Goodies know that I already have primers for HTML and for creating advertising banners. Why not JavaScript? Good question!

In an effort to put primers together, I bought the books, read them, read them again and gave up. JavaScript books, at least the four I read, are so dry and hard to follow. They’re textbooks. We all know how fun those are to bull through. So, I created a Java Goodies Web site. I figured that if I couldn’t teach you to make your own JavaScripts, then I would supply you with as many ready-made scripts as I could. Then maybe you wouldn’t need to write scripts. Well, it seemed like a smart idea at the time. Java Goodies had over 500 scripts (you can find them and over 2000 others at javascripts.com) and you still want JavaScript Primers. I should have seen it coming.


My Co-Author

I figured if I was going to do this correctly, I should have someone help me who knew what she was doing. Andree Growney is the Director of Instructional Technology Support Services and Webmaster at my university and is a bit of a wizard at this JavaScript stuff. One day I asked if she would be interested in putting a book together on how to write JavaScript and posting it to the HTML Goodies Web site. To my amazement and great joy, she said yes! So, we got started.


How You Will Learn

So, now you think I know nothing about JavaScript, and I’m relying on Andree to pull me through. Not as much as you’d think. I’ve actually got a pretty good handle on it, in spite of the books. In fact, my method of learning the language is the method these primers — and hopefully you — will follow.

     Every script that was sent to Java Goodies came via e-mail. Usually that did quite a number on the script. Scripts arrived bent, folded, and mutilated in all sorts of funny shapes. It was my job to put them back together so they would work again. So, after doing that a couple hundred times, I found I was using my reference books less and less. I could look at a script and see what the problem was. Error messages stopped sending me into a rage. I was learning JavaScript.

There’s more and more research showing that teaching by lecturing doesn’t work. When you read a textbook, you are essentially being lectured. These primers are going to try to come at it from a different angle.

     The best way to learn this stuff is in a classroom with a teacher who can help you do projects and create while you learn. These primers can’t do that, as this is still going to be a one-way conversation over the Internet, but hopefully we can do better than the books by working backward.

A wise man once said, “Tell me and I forget. Show me and I remember. Involve me and I learn.” The purpose here is to involve you.

     Each of these 30 primers will display one JavaScript and tear it apart so you can see how it works. You see, you have to be taught why something works, not just shown that it works. Case in point: David Copperfield doesn’t close the door on his assistant, open it, and exclaim “Son of a gun! She’s gone again!” He knows why she disappeared. All you know is that he shut the door and she went away.

     You both know that the box works, only he knows why it works. He will be in a better position to create another trick, whereas you’ll just keep closing the door, hoping it’ll work.


The Format of the Primers

First off, there are 30 of them. Each uses the same method.


  • First, you’ll get a brief CONCEPT statement regarding what the script is supposed to do and what the example is supposed to teach you.
  • Second, you’ll see the script in text form.
  • Third, you’ll see the script’s effect.
  • Fourth, we will tear the script apart looking at the building blocks used to create the whole.
  • Fifth, you’ll find a button marked, “What You Have Learned.” Click that button and the screen will split, showing all the JavaScript commands you’ve been shown up to that point. Each command will be a hypertext link to a brief description.
  • Finally, each primer has an assignment. You will be asked to alter the script you’ve just worked on so that it will be a little different. Maybe you’ll be given the same script, except it might be altered so that it throws errors. Either way, you will be asked to create 30 new scripts from the 30 we give you.


Let’s Get Started

Be careful going through these. Often students will want to roll through the primers as fast as possible. Most of the time that leads to commands getting jumbled up in the mind. Your brain needs time to digest all of this. If I might make a suggestion, don’t do more than two
primers a day.

     Students tell me they read the entire chapter, yet cannot remember what they read. That’s because getting to the end was the goal, not getting the most out of the reading. Speed kills. Give your brain time. Here’s an example. You read all of this, right? Well, without looking up the page… tell me the name of my co-author. I’ve written it three times now.

You rolled before you crawled, before you walked, before you ran. Give your brain time to roll around the easy scripts.

Start by reading the

Table of Contents


Why Now?
My Co-Author
How You Will Learn
Primer Format



On to JavaScript Primer #1


*JavaScript is a registered trademark of Sun Microsystems, Inc.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Popular Articles

Featured