Funciones flecha Javascript con Arrays – Ejemplo

Os dejamos un ejm Javascript de función flecha (arrow function) aplicado sobre un Array. La sintaxis es la siguiente:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Arrow Function con Arrays</title>
  </head>

  <body>
    <h1>Arrow Function con Arrays</h1>

    <script>
      const numeros = [1, 2, 3, 4, "Hola"];
      numeros.forEach((e, index) => {
        console.log(`El elemento "${e}" está en la posición ${index}`);
      });
    </script>
  </body>
</html>
Scroll al inicio