Saturday, November 20, 2010

Lesson 7: Translating Javanese, Advanced

Functions are a building block of Javascript. A function is a group of commands and statements that can be called by an event or script.

The template for defining a function:

function myFunctionName( [param1, param2...] ) {
/ / Function code goes here
}

And then to call it:

myFunctionName( x, y... );

Some examples of functions I've used are alert() and checkRequired().


Javascript is definitely more complicated than I anticipated. A How-To book and the Internet are your best friends in this matter. If you want to do something with Javascript, chances are someone out there has already figured out how to do it. Instead of reinventing the wheel, look it up.

Of course, it helps to know what you're looking at, which is where the How-To book earns its money. It can give you a quick and dirty crash course so that you know what you're doing when you add someone else's Javascript coding to your site - or may even help you customize it!

Good luck with your Java-ing!

No comments:

Post a Comment