I did some browsing of the animation source code for page scroll that
I sent today.

The plugin is written in javascript using some techniques in object
oriented programming.

Javascript is different from other OO languages like perl in which OO
is optional.

There is concept of class and object.

But Javascript is a language in which functions are first class
entities.It is a prototype programming language.

So you can as well use a function as a hash value. And pass a function
as a parameter to some other function.

It also supports functional programming constructs like closures and
anonymous functions.

The usual programming style in javascript is actually assigning
functions as a huge associative array or hash data structure
 as key value pairs. Function name is the key and the function
body/definition is the value.

Objects are used in perl also similarly.

In perl also objects are nothing but hash tables.

But javascript uses it in a very efficient and totally different manner.

And jQuery plugin uses certain javascript constructs that confused me a lot.

But I am slowly coming to terms with it now.

You extend the jQuery $ object and act on the object using the each() method.

Anyway the idea of functions being used as data itself is something
that was foreign to me having come from a C background.

Functions are code. Not data.

But in javascript and in jQuery plugins you find that functions are
stored as data as hash values.

Just like perl the array and hash syntax are similar.

Please install spidermonkey and type this.

$ js
js> a = [2,2,3, 40 ]

It is an array.

$ js
js> a={1: "Girish", 2: "Lug"}
({1:"Girish", 2:"Lug"})
js>
js> a[1]
"Girish"
js> a[2]
"Lug"

This is an associative array or hash.

-Girish

-- 
Gayatri Hitech
http://gayatri-hitech.com
_______________________________________________
ILUGC Mailing List:
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc
ILUGC Mailing List Guidelines:
http://ilugc.in/mailinglist-guidelines

Reply via email to