P
ROTOTYPE
I'm Not Only The Prototype, I'm Also A Member.
home
▪
stats
▪
search
▪
linkback
▪
about
▪
FAQ
| user: guest,
login
,
register
Array
:
Array.prototype.join_2
author:
black
[+]
,
Submitted: 07.16.03 3a
/******************************** Array.prototype.join_2 ************************************* Flashed by black Description: This function could be regarded as extension of built-in join method. It also returns a string which contains all elements with a delimiter between every two of them. Unlike join method you could set an omission option which will cause omitting the delimiter when an element found to be equal with it. **********************************************************************************************/ Array.prototype.join_2 = function(delimiter, omission) { var len = this.length; var result = ""; for (var i=0; i<len; i++) { result += (this[i] != omission) ? this[i] + ((i != len - 1) ? delimiter : "") : ""; } return result; }
usage
[b] you could set an omission option which will cause omitting the delimiter when an element found to be equal with it. [/b] for example: // omitting inserting the delimiter if any element is empty~ arr = ["a", "b", "", "d"]; var result = arr.join_2("-", ""); trace(result);
Add Comment
[+]
›opyleft 2001-2010. Layer51 is: Jaime Prado.
@