JAVASCRIPT - HOW TO Add Non Duplicates to Textarea - Javascript Source Code

JAVASCRIPT - HOW TO Line by Line Strings to Textarea Prevent the Addition of Duplicates to the Textarea.

Home Short:

The Javscript function below takes items in a textarea and removes any duplicate lines. This Javascript function does this without long processor hogging loops by ...

  1. Putting the contents of the textarea into an array by splitting the value in the textarea, line by line, while simutaneously removing any blank or emppty lines.
  2. The array is then turn into a Javascript SET which automatically removes duplicates from the array.
  3. The SET is then converted back to an array using the built in Javascript ARRAY.FROM.
  4. The array is then joined or put back together, each element of the array separated by a carriage return and then this is put back into the textarea.

Try this function to remove duplicates from a textarea yourself


S
H
A
R
E