I state that I have tried for a long time before writing this post.
For an InDesign script, I\'m working with two array of ListItems. Now I\'m trying to remove the items
Array.prototype.contains = function ( object )
{
var i = 0, n = this.length;
for ( i = 0 ; i < n ; i++ )
{
if ( this[i] === object )
{
return true;
}
}
return false;
}
Array.prototype.removeItem = function(value, global) {
var idx;
var n = this.length;
while ( n-- ) {
if ( value instanceof RegExp && value.test ( this[n])
|| this[n] === value ) {
this.splice (n, 1 );
if ( !global ) return this;
}
}
return this;
};
arr_A = ["a","b","d","f","g"];
arr_B = ["a","c","f","h"];
var item
while ( item = arr_A.pop() ) {
arr_B.contains ( item ) && arr_B.removeItem ( item );
}
arr_B;