Remove an entry from an array of strings


//remove an entry (string) from a list of strings
Array.prototype.removeEntry = function( entry:String ) {

	if ( @IsNotMember(entry, this)) {
		return this;
	}
			
	var res = @Trim( @Replace(this, entry, "") );
	return (typeof res == "string" ? (res.length==0 ? [] : [res]) : res);
	
}
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
2 comment(s)Login first to comment...
yunus myunus
(at 08:54 on 11.02.2019)
this works great in 2019 :) saved me
Steve Smillie
(at 14:46 on 24.04.2013)
Thanks!!
I thought I was going crazy, until I realized that splice on an a array in SSJS was the problem.
This worked well to remove from an array.