/array-destructuring.html Secret
Created
June 19, 2023 19:39
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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