Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Arrays</h1> <h2>Array Destructuring</h2> <p>Move array variables into single variables:</p> <p id="demo"></p> <script> // Create an Array const fruits = ["Bananas", "Oranges", "Apples", "Mangos"]; // Destructuring let [fruit1, fruit2] = fruits; // Display Primitive Values document.getElementById("demo").innerHTML = fruit1 + " " + fruit2; </script> </body> </html>