Exécuter
❯
Exécuter le code
Ctrl+Alt+R
Sauvegarder le code
Ctrl+Alt+A
Changer d'orientation
Ctrl+Alt+O
Changer de thème
Ctrl+Alt+D
<!DOCTYPE html> <html> <body> <h1>Tableaux JavaScript</h1> <h2>La méthode from()</h2> <p>La méthode from() peut renvoyer un tableau à partir de n'importe quelle variable ayant une propriété length.</p> <p>Il peut renvoyer une chaîne sous forme de tableau :</p> <p id="demo"></p> <script> const myNumbers = [1,2,3,4]; const myArr = Array.from(myNumbers, (x) => x * 2); document.getElementById("demo").innerHTML = myArr; </script> </body> </html>