Hi Obi-wan Kenobi,
what do you really want to do?
Remove one part of an array by name?
You know ExtendScript does not allow a "getByName in array". That's why: There is no good or bad writing – it is always a case distinction. If you use the "change-array-to-string-and-back-method" you don't need a loop and you can use replace and other "regex methods". This seems to be a small advantage.
But be sure – IMHO it is better to use the global "g-parameter" in the replace method too. And I think leave the array A as it is and create a new Array B with all the changings. And I prefer array.join() instead of array.toString(). This method is more flexible for me.
var A = ["Blue","Red","Green","White","Black","Red"]; var B = A.join().replace(/,Red/g,"").split(","); $.writeln(B);
also notice, that pixxxel schubser is using the g parameter for his regular expression.
It wasn't clear from the start, if you want to remove the first instance of the string or all instances (if there are any).
Or if that type of array should only contain unique strings…
If all strings are unique when starting with array A, a loop could be terminated with break after the string is found and A.splice(a,1) is done. That would reduce the amount of time running the loop, if the string is not the last entry in the array.