Skip to content

Instantly share code, notes, and snippets.

@cferdinandi
Created June 19, 2023 19:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Array Destructuring</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script>
let lunch = ['turkey sandwich', 'soda', 'chips', 'cookie'];
// Traditional approach
// let entree = lunch[0];
// let drink = lunch[1];
// let side = lunch[2];
// let desert = lunch[3];
// Destructuring
let [entree, drink, side, desert] = lunch;
console.log(entree);
console.log(side);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment