Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Add simple destructing with es6
Browse files Browse the repository at this point in the history
  • Loading branch information
sicktastic committed Sep 2, 2017
1 parent e2d7ca8 commit b1c0c55
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions es6/destructuring.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict';

// Example 1
// let toybox ={ item1: 'care', item2: 'ball', item3: 'frisbee' }
// let {item1, item2} = toybox;
// console.log(item1);

// Example 2
// let widgets = ['widget1', 'widget2', 'widget3', 'widget4', 'widget5'];
// let [a, b, c, ...d] = widgets;
// console.log(d);

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);
})

0 comments on commit b1c0c55

Please sign in to comment.