bookmark_borderfunction call in javascript

I was studying russkey.mozdev.org source code to learn how to write Firefox extension.

Found this style of function call in javascript.


var collection = {

hello : function() {
document.write("Hello World!");
},

understand : function() {
document.write("<br/>Understand!");
},

bye : function() {
document.write("<br/>bye!");
}

};


var m = new collection.hello();
var n = new collection.understand();
var o = new collection.bye();

The output will


Hello World!
Understand!
bye!

bookmark_borderCheck date in Java Script

here is my date check javascript.

function leapyearcheck(year)
{

if(year.value % 4 != 0)
{
return 0;
}

else
{
if(year.value % 100 != 0)
{
return 1; //leap year
}

else
{

if(year.value % 400 != 0)
{
return 0
}

else
return 1; //leap year

}

}
}


function datecheck(day,month,year) //call this function
{
//alert(day.value);

if(!leapyearcheck(year))
{
//alert("Not Leap Year");

if(month.value == 2)
{
if(day.value > 28)
{
alert("Check the Day and Month");
return false;
}

}
}

else

{

//alert("Leap Year");
if(month.value == 2)
{
if(day.value > 29)
{
alert("Check the Day and Month");
return false;
}
}

}


Thanks to HasinHyder for a tricky one..

var dt = new Date(year+"/02/29");
if (dt.getMonth()=="1")
alert (year + " is a leap year");
else
alert(year + " is not a leap year")