fork download
  1. Array.prototype.duplicates = function() {
  2. return this.filter((x, y, z) => {
  3. return y !== z.lastIndexOf(x);
  4. });
  5. }
  6.  
  7. // retornarĂ¡ somente os valores duplicados do array
  8. console.log(["js", "php", "html", "js", "css", "php"].duplicates()); // [js, php]
Success #stdin #stdout 0.03s 17132KB
stdin
Standard input is empty
stdout
js,php