Thread: Cookies and OOP
View Single Post
Old 01-11-2003, 11:37 AM   PM User | #7
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Ya Skyzyx, you got it right. What jkd used is called an object literal. The same way this
Code:
var nums = [1,2,3,4];
is the literal syntax for this
Code:
var nums = new Array(1,2,3,4);
For objects, this
Code:
var nums = { M: 1000, D:500, C:100, L:50, X:10, V:5, I:1 }
is the same as doing this
Code:
var nums = new Object();
nums.M = 1000;
nums.D = 500;
nums.C = 100;
nums.L = 50;
nums.X = 10;
nums.V = 5;
nums.I = 1;
Since functions are just another variable type in javascript, jkd is just assigning functions to his CookieJar object's properties to make them methods.

About the parameter passing thing with anon function...that's not really an anonymous function, it's name is fill and you can't pass parameters like that.

Hope I've helped
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote