March 11, 2007

Function Arguments Array

Inside every function in JavaScript there exists a contextual variable named arguments that acts like a pseudo-array. This object contains all the arguments passed in to the function. Arguments isn't a true array (meaning that you can't modify it, or call .push() to add new items), but you can access items in the array, and it does have a length property.

(read more...)

August 11, 2006

JavaScript Functions 101

A function is a self-contained block of statements. Functions are very good at holding reusable code. You can declare a function by using the function keyword followed by the name of the function you want to create:

function myfunction() {
     // do something
}

You execute the function like this:

myfunction();

(read more...)