Welcome to MoiK78 blog. Your daily intake of Internet news. This is a personal site so I post whenever I can :) but I'll try to get it daily. Be free to email me any suggestion. El bolg de Moisés García sobre tecnologías de internet y programas de diseño.
Homepage About Me Contact Me Buy at MoiK78 online shop Downloads

Welcome to MoiK78 blog, your daily intake of internet and technology news.

Picasa Web Albums My Picasa Photo Albums / Albumes de Fotos

November 15, 2002

New custom Array methods.
I'm going to continue with some useful methods for the Array object. The first one makes a copy of the array, not a reference of it.
Array.prototype.Copy=function(){
return this.slice(0)
}

Usage:
array0 = [1, 2, 3, 4];
array1 = [array0, 2, 3, 4];
array2 = array1.Copy();


The second one checks if two arrays are identical, so they have the same elements.
Array.prototype.IdenticalArray = function (Array2) {
for(var i=0;i < this.length;i++){
if(this[i] !== Array2[i]){
return false;
}
}
return true;
}

Usage:
array1 = [1, 2, 3, 4];
array2 = ["1", 2, 3, 4];
if (array1.IdenticalArray(array2)) {
trace("The arrays are identical");
} else{
trace("The arrays are NOT identical");
}


 
Site Meter