Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const miarray = ["Torta de Chocolate", "Gelatina de Fresa", "Pie de Limón", "Torta de Chocolate"];
- /* Método 1
- const ns = new Set(miarray);
- const arrayunico = [...ns]
- console.log(arrayunico);
- */
- /* Método 2
- const nuevoarray = miarray.filter((item, index) => {
- return miarray.indexOf(item) === index;
- });
- console.log(nuevoarray);
- */
- // Método 3
- const nuevoarray = miarray.reduce((unique, item) => {
- return unique.includes(item) ? unique : [...unique, item];
- }, []);
- console.log(nuevoarray);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement