Created
September 9, 2017 10:56
-
-
Save bosr/6b4684d947d42395bfb9330bea1acaf5 to your computer and use it in GitHub Desktop.
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
'use strict'; | |
let widgets = ['widget1', 'widget2', 'widget3', 'widget4', 'widget5']; | |
let [a, b, c, ...d] = widgets; | |
console.log(a); // logs widget1 | |
console.log(b); // logs widget2 | |
console.log(d); // logs ['widget4', 'widget5'] |
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
'use strict'; | |
function getData({ url, method = 'post' } = {}, callback) { | |
callback(url, method); | |
} | |
getData({ url: 'myposturl.com' }, function (url, method) { | |
console.log(url, method); | |
}); | |
getData({ url: 'myputurl.com', method: 'put' }, function (url, method) { | |
console.log(url, method); | |
}); | |
// logs | |
// myposturl.com post | |
// myputurl.com put |
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
'use strict'; | |
let parentObject = { | |
title: 'Super Important', | |
childObject: { | |
title: 'Equally Important' | |
} | |
} | |
let { title, childObject: { title: childTitle } } = parentObject | |
console.log(childTitle); | |
// log: Equally Important |
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
'use strict'; | |
let toybox = { item1: 'car', item2: 'ball', item3: 'frisbee' }; | |
let {item1, item2} = toybox; | |
console.log(item1, item2); | |
// logs: car ball | |
let {item3: disc} = toybox; | |
console.log(disc); | |
// logs: frisbee |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment