Skip to content

Instantly share code, notes, and snippets.

@tanaikech
Created September 6, 2017 07:49
Show Gist options
  • Save tanaikech/c1c1fa40062477ad028c6ecdeef62634 to your computer and use it in GitHub Desktop.
Save tanaikech/c1c1fa40062477ad028c6ecdeef62634 to your computer and use it in GitHub Desktop.
Removing Duplicated Values in Array using CoffeeScript

Removing Duplicated Values in Array using CoffeeScript

This sample script is for removing duplicated values in array using CoffeeScript.

ar = ["a", "b", "c", "a", "c"]
res = ar.filter (e, i, s) -> s.indexOf(e) is i
console.log res

>>> [ 'a', 'b', 'c' ]

The result which was compiled by CoffeeScript is as follows.

var ar, res;
ar = ["a", "b", "c", "a", "c"];
res = ar.filter(function(e, i, s) {
  return s.indexOf(e) === i;
});
console.log(res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment