At 2001-03-30 10:33, you wrote:
>>[...]
>>So we need (want):
>>array.splice();
>
>Yes !, If someone has a complete implementation
WebReference.com wrote an article about this in their Array Power series.
Part 1 covers background information and shift()/unshift():
http://www.webreference.com/dhtml/column31/
Part 2 provides push()/pop():
http://www.webreference.com/dhtml/column32/
Part 3 finally has the splice() method:
http://www.webreference.com/dhtml/column33/
>>isArray(a); <-- is there not a typeOf() in JS? If not, would typeOf () be
>>acceptable?
>
>Yes, but it seems, as far as I remeber, that typeOf(enArray) returns "object", so you
>can't really know from that wheteher it is an array or not..
>
>
>
>>Array.prototype.toString()
>
>Just to print it out like "[foo, bar, gee]"
>
>
>
>>Array.prototype.push(element)
>>Array.prototype.pop()
>>
>>deleteAndPack(array, indice) (equivalent to removeFromArray) <-- let's just
>>call it removeFromArray(index/id); ?
>
>Ok for me...
>
>
>
>>String.prototype.trim() < -- I've been wanting this one for a while.. myself
>
>Someone sent it on the list a time ago....
I'm the guilty one...
// Returns a new trimmed string
// 'side' is which side to trim. Can be "left", "right" or "both" (default)
String.prototype.trim = function(side) {
switch(side) {
case "left":
return this.replace(/^\s+/, "");
case "right":
return this.replace(/\s+$/, "");
default:
return this.replace(/^\s+|\s+$/g, "");
}
}
// These class functions don't require 'str' to be strings as the toString() method is
called
String.Trim = function(str) { return str.toString().trim(); }
String.LTrim = function(str) { return str.toString().trim("left"); }
String.RTrim = function(str) { return str.toString().trim("right"); }
// These are for VBScript-feeling
function Trim(str) { return str.toString().trim(); }
function LTrim(str) { return str.toString().trim("left"); }
function RTrim(str) { return str.toString().trim("right"); }
>Note that for all the methods I proposed, I can send some code in.
>I also have a 'Array.prototype.getUnique()' method, which returns the array whithout
>any duplicate element. May help sometimes...
>
>Marc
Please do.
/Lunna
_______________________________________________
Dynapi-Dev mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-dev