Created
March 26, 2019 03:08
-
-
Save micahriggan/869d42a2e22a105fc491c1882ef11fc9 to your computer and use it in GitHub Desktop.
Simple examples of destructuring params
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
function log(...args) { | |
console.log(args); | |
} | |
function getName({name}) { | |
console.log(name); | |
} | |
function pop([first, ...rest]) { | |
return rest; | |
} | |
function push(array, elem) { | |
return [...array, elem]; | |
} | |
function test1() { | |
log("Hello", "World") | |
} | |
function test2() { | |
getName({name: 'Micah', points: 100}); | |
} | |
function test3() { | |
console.log(pop(["First", "Second", "Third"])); | |
} | |
function test4() { | |
console.log(push(["First"], "Second")); | |
} | |
test1(); | |
test2(); | |
test3(); | |
test4(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment