{"id":1137,"date":"2019-06-27T23:00:00","date_gmt":"2019-06-27T23:00:00","guid":{"rendered":"https:\/\/weichie.com\/javascript-array-and-object-destructuring-with-es6\/"},"modified":"2024-02-05T15:44:33","modified_gmt":"2024-02-05T15:44:33","slug":"javascript-array-and-object-destructuring-with-es6","status":"publish","type":"post","link":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/","title":{"rendered":"Javascript Array and Object destructuring with ES6"},"content":{"rendered":"<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">Yet another destructuring post.. It&#8217;s a function I always forget that exists in javascript, so I hope this post can show you it&#8217;s power and beauty, so you&#8217;ll remember! The javascript destructuring assignment makes it possible to extract data from arrays and objects into distinct variables. Without declaring them first! A ma zing!!<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<!--more-->\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h2 class=\"wp-block-heading\"><figure><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-868\" src=\"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/js_es6_destructuring.png\" alt=\"\" width=\"2740\" height=\"1828\"><\/figure><\/h2>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h2 class=\"wp-block-heading\">Javascript simple destructuring examples<\/h2>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">We can destructure both javascript Objects or Arrays. I&#8217;ll start simple with a few examples below to get the hang of it. But when we&#8217;re using complex JSON data-structures, destructuring can really help us out. (See complexer JSON example at the bottom)<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h3 class=\"wp-block-heading\">Javascript Array Destructuring<\/h3>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<pre><code class=\"language-javascript\">const testArray = [1, 2, 3, 4, 5];\nconst a = testArray;\nconst [x, y, z] = testArray;\nconsole.log(a);      \/\/ a =&gt; (5)&nbsp;[1, 2, 3, 4, 5]\nconsole.log(x, z);   \/\/ x =&gt; 1, z =&gt; 3<\/code><\/pre>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h3 class=\"wp-block-heading\">Javascript Object Destructuring<strong><br>\n<\/strong><\/h3>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<pre><code class=\"language-javascript\">const testObject = {\n  firstname: \"Bob\",\n  lastname: \"Weichler\"\n};\nconst a = testObject;\nconst { firstname } = testObject;\nconsole.log(a);           \n\/\/ a =&gt; {firstname: \"Bob\", lastname: \"Weichler\"}\nconsole.log(firstname);\n\/\/ firstname =&gt; Bob<\/code><\/pre>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">As you can see, the first item (a) just returns the initial value. When we use destructuring, we can get the direct value of the preferred items, without declaring them first. Which is awesome, and makes it possible to do wicked stuff way faster!<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\"><em>Notice that destructuring an array uses <strong>let [x] = value;<\/strong><br>\nwhile an object uses <strong>let {name} = value;<\/strong><\/em><\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">Another thing we can do, is destructure the variables directly when declaring them. Wait&#8230; What?<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<pre><code class=\"language-javascript\">const [val1, val2] = [\"JS\", \"Destructuring\", \"101\"];\nconsole.log(val1);  \/\/ val1 =&gt; JS\nconsole.log(val2);  \/\/ val2 =&gt; Destructuring\nconst {val1, val2} = {val1: \"JS\", val2: \"Destructuring\" };\nconsole.log(val1);  \/\/ val1 =&gt; JS\nconsole.log(val2);  \/\/ val2 =&gt; Destructuring<\/code><\/pre>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\"><em>Notice: For an array, the variable names doesn&#8217;t matter<span style=\"font-weight: 400;\">, as it takes the position from the array element<\/span>. But for objects it does! we can&#8217;t do the following&nbsp;<strong>const {val1} = {test: &#8220;whoow&#8221;}<\/strong>&nbsp;because it will return undefined.<br>\n<\/em><\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h2 class=\"wp-block-heading\">Deeper level destructuring (nested items)<\/h2>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">We can also destructure immediately on deeper nested elements. Let&#8217;s start with a 1-level nested array or object:<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<pre><code class=\"language-javascript\">const testArray = [\n    [\"Bob Weichler\", \"Webdeveloper\"],\n    [\"John Doe\", \"Webdesigner\"]\n];\nconst [ firstUser ] = testArray; \n\/\/ firstUser =&gt; (2)&nbsp;[\"Bob Weichler\", \"Webdeveloper\"]\nconst dataObj = {\n    users: {\n        name: 'Bob'\n    }\n}\nconst { users: {name} } = dataObj;\n\/\/name =&gt; Bob\n  <\/code><\/pre>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">You still with me? What if we want to go even deeper? For an Array, we need to start mapping if we want to go deepter. See an example further down this post. For objects we can see where we&#8217;ll end:<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<pre><code class=\"language-javascript\">const dataObj2 = {\n    users: {\n        name: {\n            first: 'Bob',\n            last: 'Weichler'\n        }\n    }\n}\nconst { users: { name } } = dataObj2;\nconst { first } = name;\n\/\/ first =&gt; Bob<\/code><\/pre>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">I couldn&#8217;t manage to destructure directly 3 levels deep \ud83d\ude41 Let me know if you found a way! (without looping)<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h2 class=\"wp-block-heading\">Spreading, rest or skipping some values<\/h2>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">Now that we&#8217;re already destructuring like a maniac, why not throw some extra&#8217;s in it like a spread or a skip?<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<pre><code class=\"language-javascript\">\/\/ -- REST AT ONCE ----------\nconst dataObj = {\n    users: {\n        name: 'Bob Weichler',\n        job: 'Webdeveloper',\n        country: 'Belgium',\n        age: 25\n    },\n}\nconst { users: { name, ...rest } } = dataObj;\n\/\/ name =&gt; Bob Weichler\n\/\/ rest =&gt; {job: \"Webdeveloper\", country: \"Belgium\", age: 25}\n\/\/ -- SKIPPING ITEMS ----------\nconst countries = ['Belgium', 'France', 'Germany', 'Singapore', 'Mexico'];\nconst [ home, , skipFrance, ...otherCountries ] = countries;\n\/\/ skipFrance =&gt; Germany\n\/\/ otherCountries =&gt; (2) [\"Singapore\", \"Mexico\"]<\/code><\/pre>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h2 class=\"wp-block-heading\">Mixed destructuring and more complex Structures<\/h2>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">This is all fun and games, but not really time winning in my opinion. However, I recently started experimenting with the WordPress REST API, and oh boy.. this one kind of forced me into using javascript destructuring. We all know WordPress abuses the posts and postmeta tables, and then combined with <a href=\"https:\/\/www.advancedcustomfields.com\/pro\/\" target=\"_blank\" rel=\"noreferrer noopener\" class=\"ua-link\" aria-label=\"ACF (opens in a new tab)\">ACF<\/a>.. do we even want to see the returned JSON? If we don&#8217;t specify our call a little, it <span style=\"font-weight: 400;\">literally<\/span> returns everything.<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">If we filter the json result a little, we can assume the following data to work with:<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<pre><code class=\"language-javascript\">const research = {\n    id: 445,\n    data: \"2019-05-13T00:00:00\",\n    otherContent: \"...\",\n    acf: {\n        relatedStaff: [{\n            staffLevel: 'Supervisors',\n            users: [{\n                name: { first: 'Bob', last: 'Weichler' }\n            },{\n                name: { first: 'Jane', last: 'Doe' }\n            }]\n        },{\n            staffLevel: 'Reseachers',\n            users: [{\n                name: { first: 'John', last: 'Doe' }\n            }]\n        }]\n    },\n    ...\n}<\/code><\/pre>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">In my example, I wanted to return all related users. No matter to what research group they belong to. This is where the fun started, and is also the reason why I wrote this post..<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h3 class=\"wp-block-heading\">Return all related users:<\/h3>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<pre><code class=\"language-javascript\">getRelatedUsers = ( result = [] ) =&gt; {\n    const { acf: { relatedStaff } } = research;\n    relatedStaff.map(({ users }) =&gt; {\n        users.map(({ name: { first, last } }) =&gt; {\n            result.push(`${first} ${last}`);\n        });\n    });\n    return result;\n}\n\/* output: getRelatedUsers() =&gt; (3)&nbsp;[\"Bob Weichler\", \"Jane Doe\", \"John Doe\"] *\/<\/code><\/pre>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">Woah, relax! A little bit more info pleasee.<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">1 &#8211; First we create a function&nbsp;<strong>getRelatedUsers()<\/strong> so we can use this function everywhere in our app<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">2 &#8211; Declare a result parameter inside our function parameters, to win time<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">3 &#8211; Destructure our ACF relatedStaff field from our json object, notice that relatedStaff is an array in our json object<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">4 &#8211; Because this is an array, we need to map() over it, to <span style=\"font-weight: 400;\">retrieve<\/span> the data from every row<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">5 &#8211; While mapping, we directly pull the users object with destructuring. Users will also be an array, we can map() over again<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">6 &#8211; While mapping over the users, we declare our first and last name, inside the map parameters<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">7 &#8211; Store the names for each row inside our declared result array<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<h2 class=\"wp-block-heading\">Javascript Destructuring Challenge!<\/h2>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">Hope this post gave you more insights on how destructuring works, and when it can become handy in our applications.<\/p>\n<\/div>\n\n<div class=\"default__block container-fluid lg\">\n<p class=\"wp-block-paragraph\">Please feel free to contribute to my getRelatedUsers() function in the comments! If we can make it compacter, let&#8217;s do so!<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Yet another destructuring post.. It&#8217;s a function I always forget that exists in javascript, so I hope this post can show you it&#8217;s power and beauty, so you&#8217;ll remember! The javascript destructuring assignment makes it possible to extract data from arrays and objects into distinct variables. Without declaring them first! A ma zing!!<\/p>\n","protected":false},"author":1,"featured_media":745,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[211],"tags":[259,260,162,261],"class_list":["post-1137","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-development-nl","tag-destructuring-nl","tag-es6-nl","tag-javascript-nl","tag-tutorial-nl"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.9 (Yoast SEO v27.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Javascript Array and Object destructuring with ES6 - Weichie.com<\/title>\n<meta name=\"description\" content=\"Use javascript destructuring to win time and to allow us to easely strip compact code. JS Destructuring with ES6 is really amazing when done right!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/\" \/>\n<meta property=\"og:locale\" content=\"nl_NL\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Javascript Array and Object destructuring with ES6 - Weichie.com\" \/>\n<meta property=\"og:description\" content=\"Use javascript destructuring to win time and to allow us to easely strip compact code. JS Destructuring with ES6 is really amazing when done right!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/\" \/>\n<meta property=\"og:site_name\" content=\"Weichie.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/weichiecom\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-27T23:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-05T15:44:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/vue-head-with-title.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"413\" \/>\n\t<meta property=\"og:image:height\" content=\"82\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"weichie\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Javascript Array and Object destructuring with ES6\" \/>\n<meta name=\"twitter:description\" content=\"Use javascript destructuring to win time and to allow us to easely strip compact code. JS Destructuring with ES6 is really amazing when done right!\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/vue-head-with-title.jpg\" \/>\n<meta name=\"twitter:label1\" content=\"Geschreven door\" \/>\n\t<meta name=\"twitter:data1\" content=\"weichie\" \/>\n\t<meta name=\"twitter:label2\" content=\"Geschatte leestijd\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minuten\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/\"},\"author\":{\"name\":\"weichie\",\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#\\\/schema\\\/person\\\/36b4fff07382bc08a5c566728d9c579f\"},\"headline\":\"Javascript Array and Object destructuring with ES6\",\"datePublished\":\"2019-06-27T23:00:00+00:00\",\"dateModified\":\"2024-02-05T15:44:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/\"},\"wordCount\":656,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/weichie.com\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/js_es6_destructuring.png\",\"keywords\":[\"destructuring\",\"ES6\",\"javascript\",\"tutorial\"],\"articleSection\":[\"Development\"],\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/\",\"url\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/\",\"name\":\"Javascript Array and Object destructuring with ES6 - Weichie.com\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/weichie.com\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/js_es6_destructuring.png\",\"datePublished\":\"2019-06-27T23:00:00+00:00\",\"dateModified\":\"2024-02-05T15:44:33+00:00\",\"description\":\"Use javascript destructuring to win time and to allow us to easely strip compact code. JS Destructuring with ES6 is really amazing when done right!\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/#breadcrumb\"},\"inLanguage\":\"nl-NL\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/#primaryimage\",\"url\":\"https:\\\/\\\/weichie.com\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/js_es6_destructuring.png\",\"contentUrl\":\"https:\\\/\\\/weichie.com\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/js_es6_destructuring.png\",\"width\":2000,\"height\":1334},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/blog\\\/javascript-array-and-object-destructuring-with-es6\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/weichie.com\\\/nl\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Javascript Array and Object destructuring with ES6\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#website\",\"url\":\"https:\\\/\\\/weichie.com\\\/nl\\\/\",\"name\":\"Weichie.com\",\"description\":\"Digital Agency in Brussels &amp; New York\",\"publisher\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#organization\"},\"alternateName\":\"Weichie\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/weichie.com\\\/nl\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"nl-NL\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#organization\",\"name\":\"Weichie.com\",\"alternateName\":\"Weichie\",\"url\":\"https:\\\/\\\/weichie.com\\\/nl\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"nl-NL\",\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/weichie.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/Weichie_full.png\",\"contentUrl\":\"https:\\\/\\\/weichie.com\\\/wp-content\\\/uploads\\\/2023\\\/11\\\/Weichie_full.png\",\"width\":1181,\"height\":177,\"caption\":\"Weichie.com\"},\"image\":{\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/weichiecom\\\/\",\"https:\\\/\\\/www.instagram.com\\\/weichiecom\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/weichie\\\/\"],\"description\":\"A digital agency based in Brussels and New York. We create high-quality digital experiences for brands and help them promote their business through the online world! Specialised in websites, e-commerce, SEO and applications.\",\"email\":\"hello@weichie.com\",\"telephone\":\"+32 469 129 449\",\"legalName\":\"Weichie.com\",\"vatID\":\"0782.257.983\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"1\",\"maxValue\":\"10\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/weichie.com\\\/nl\\\/#\\\/schema\\\/person\\\/36b4fff07382bc08a5c566728d9c579f\",\"name\":\"weichie\",\"sameAs\":[\"https:\\\/\\\/weichie.com\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Javascript Array and Object destructuring with ES6 - Weichie.com","description":"Use javascript destructuring to win time and to allow us to easely strip compact code. JS Destructuring with ES6 is really amazing when done right!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/","og_locale":"nl_NL","og_type":"article","og_title":"Javascript Array and Object destructuring with ES6 - Weichie.com","og_description":"Use javascript destructuring to win time and to allow us to easely strip compact code. JS Destructuring with ES6 is really amazing when done right!","og_url":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/","og_site_name":"Weichie.com","article_publisher":"https:\/\/www.facebook.com\/weichiecom\/","article_published_time":"2019-06-27T23:00:00+00:00","article_modified_time":"2024-02-05T15:44:33+00:00","og_image":[{"width":413,"height":82,"url":"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/vue-head-with-title.jpg","type":"image\/jpeg"}],"author":"weichie","twitter_card":"summary_large_image","twitter_title":"Javascript Array and Object destructuring with ES6","twitter_description":"Use javascript destructuring to win time and to allow us to easely strip compact code. JS Destructuring with ES6 is really amazing when done right!","twitter_image":"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/vue-head-with-title.jpg","twitter_misc":{"Geschreven door":"weichie","Geschatte leestijd":"4 minuten"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/#article","isPartOf":{"@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/"},"author":{"name":"weichie","@id":"https:\/\/weichie.com\/nl\/#\/schema\/person\/36b4fff07382bc08a5c566728d9c579f"},"headline":"Javascript Array and Object destructuring with ES6","datePublished":"2019-06-27T23:00:00+00:00","dateModified":"2024-02-05T15:44:33+00:00","mainEntityOfPage":{"@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/"},"wordCount":656,"commentCount":0,"publisher":{"@id":"https:\/\/weichie.com\/nl\/#organization"},"image":{"@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/#primaryimage"},"thumbnailUrl":"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/js_es6_destructuring.png","keywords":["destructuring","ES6","javascript","tutorial"],"articleSection":["Development"],"inLanguage":"nl-NL","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/","url":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/","name":"Javascript Array and Object destructuring with ES6 - Weichie.com","isPartOf":{"@id":"https:\/\/weichie.com\/nl\/#website"},"primaryImageOfPage":{"@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/#primaryimage"},"image":{"@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/#primaryimage"},"thumbnailUrl":"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/js_es6_destructuring.png","datePublished":"2019-06-27T23:00:00+00:00","dateModified":"2024-02-05T15:44:33+00:00","description":"Use javascript destructuring to win time and to allow us to easely strip compact code. JS Destructuring with ES6 is really amazing when done right!","breadcrumb":{"@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/#breadcrumb"},"inLanguage":"nl-NL","potentialAction":[{"@type":"ReadAction","target":["https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/"]}]},{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/#primaryimage","url":"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/js_es6_destructuring.png","contentUrl":"https:\/\/weichie.com\/wp-content\/uploads\/2023\/02\/js_es6_destructuring.png","width":2000,"height":1334},{"@type":"BreadcrumbList","@id":"https:\/\/weichie.com\/nl\/blog\/javascript-array-and-object-destructuring-with-es6\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/weichie.com\/nl\/"},{"@type":"ListItem","position":2,"name":"Javascript Array and Object destructuring with ES6"}]},{"@type":"WebSite","@id":"https:\/\/weichie.com\/nl\/#website","url":"https:\/\/weichie.com\/nl\/","name":"Weichie.com","description":"Digital Agency in Brussels &amp; New York","publisher":{"@id":"https:\/\/weichie.com\/nl\/#organization"},"alternateName":"Weichie","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/weichie.com\/nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"nl-NL"},{"@type":"Organization","@id":"https:\/\/weichie.com\/nl\/#organization","name":"Weichie.com","alternateName":"Weichie","url":"https:\/\/weichie.com\/nl\/","logo":{"@type":"ImageObject","inLanguage":"nl-NL","@id":"https:\/\/weichie.com\/nl\/#\/schema\/logo\/image\/","url":"https:\/\/weichie.com\/wp-content\/uploads\/2023\/11\/Weichie_full.png","contentUrl":"https:\/\/weichie.com\/wp-content\/uploads\/2023\/11\/Weichie_full.png","width":1181,"height":177,"caption":"Weichie.com"},"image":{"@id":"https:\/\/weichie.com\/nl\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/weichiecom\/","https:\/\/www.instagram.com\/weichiecom\/","https:\/\/www.linkedin.com\/company\/weichie\/"],"description":"A digital agency based in Brussels and New York. We create high-quality digital experiences for brands and help them promote their business through the online world! Specialised in websites, e-commerce, SEO and applications.","email":"hello@weichie.com","telephone":"+32 469 129 449","legalName":"Weichie.com","vatID":"0782.257.983","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"1","maxValue":"10"}},{"@type":"Person","@id":"https:\/\/weichie.com\/nl\/#\/schema\/person\/36b4fff07382bc08a5c566728d9c579f","name":"weichie","sameAs":["https:\/\/weichie.com"]}]}},"_links":{"self":[{"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/posts\/1137","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/comments?post=1137"}],"version-history":[{"count":0,"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/posts\/1137\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/media\/745"}],"wp:attachment":[{"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/media?parent=1137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/categories?post=1137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/weichie.com\/nl\/wp-json\/wp\/v2\/tags?post=1137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}