
Added by roScripts on August-25-2007, 2:52 pm
// ---------------------------------------
// Array.clean
// prototype function
//
// by Davide Beltrame (Broly)
// e-mail: davb86@libero.it
//
// This function remove the empty element
// from an array
//
// Syntax
//
// arrayname.clean(to_delete)
//
// Parameter: to_delete <- element to delete from the array
//
// ----------------------------------------
Array.prototype.clean = function(to_delete)
{
var a;
for (a = 0; a < this.length; a++)
{
if (this[a] == to_delete)
{
this.splice(a, 1);
a--;
}
}
return this;
};
//Usage sample
arr= new Array("","Hello","Friend","", "Hello","","World")
trace("Original array: " + arr) //Trace original array
trace("Cleaned array: " + arr.clean("")) // Trace cleaned array (delete empty values)
//trace("Cleaned array : " + arr.clean("Hello"))
// Trace cleaned array (delete "Hello" values)
Added by roScripts on March-26-2008, 5:14 pm
Added by roScripts on March-26-2008, 5:13 pm
Added by roScripts on March-26-2008, 5:09 pm
Added by roScripts on March-26-2008, 5:08 pm
Added by roScripts on March-26-2008, 5:07 pm