Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getUniqueArray(_array)
- {// https://thispointer.com/javascript-get-unique-values-in-an-array/
- // in the newArray get only the elements which pass the test implemented by the filter function.
- // the test is to check if the element's index is same as the index passed in the argument.
- let newArray = _array.filter((element, index, array) => array.indexOf(element) === index);
- return newArray
- }
- let myArray = ["Hello", "This", "Is","Language","This", "Is" ];
- ss.info(getUniqueArray(myArray))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement