{"id":956,"date":"2015-03-22T14:11:17","date_gmt":"2015-03-22T13:11:17","guid":{"rendered":"http:\/\/abumarkub.net\/abublog\/?p=956"},"modified":"2015-03-22T14:16:36","modified_gmt":"2015-03-22T13:16:36","slug":"es6-destructering","status":"publish","type":"post","link":"https:\/\/abumarkub.net\/abublog\/?p=956","title":{"rendered":"es6 destructering"},"content":{"rendered":"<p>We want to pass a settings object to the constructor of the Data class.<\/p>\n<p>The settings object:<\/p>\n<pre><code>{\n  id: 1,\n  name: 'John'\n}\n<\/code><\/pre>\n<p>Without destructering:<\/p>\n<pre><code>class Data{\n  constructor(settings){\n    this.id = settings.id;\n    this.name = settings.name;\n  }\n}\n<\/code><\/pre>\n<p>With destructering:<\/p>\n<pre><code>class Data{\n  constructor(settings){\n    ({id: this.id, name: this.name} = settings);\n  }\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>We want to pass a settings object to the constructor of the Data class. The settings object: { id: 1, name: &#8216;John&#8217; } Without destructering: class Data{ constructor(settings){ this.id = settings.id; this.name = settings.name; } } With destructering: class Data{ constructor(settings){ ({id: this.id, name: this.name} = settings); } }<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-956","post","type-post","status-publish","format-standard","hentry","category-es6"],"_links":{"self":[{"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=\/wp\/v2\/posts\/956","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=956"}],"version-history":[{"count":4,"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=\/wp\/v2\/posts\/956\/revisions"}],"predecessor-version":[{"id":960,"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=\/wp\/v2\/posts\/956\/revisions\/960"}],"wp:attachment":[{"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=956"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=956"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abumarkub.net\/abublog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=956"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}