{"id":6715,"date":"2020-04-14T14:59:36","date_gmt":"2020-04-14T14:59:36","guid":{"rendered":"https:\/\/blog-stg.cheesecakelabs.com\/blog\/avoid-array-mutation\/"},"modified":"2022-07-01T17:09:14","modified_gmt":"2022-07-01T17:09:14","slug":"avoid-array-mutation","status":"publish","type":"post","link":"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/","title":{"rendered":"How to Avoid Array Mutation"},"content":{"rendered":"<p style=\"text-align: center;\"><em>Originally posted on <a href=\"https:\/\/dev.to\/helderburato\/how-to-avoid-array-mutation-4bpa\">dev.to<\/a><\/em><\/p>\n<p><span style=\"font-weight: 400;\">In this article, I&#8217;ll focus on showing how to add, edit and remove items in an array causing mutation and non-mutation ways.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">One thing we need to keep in mind when writing code avoiding mutation is to return a new reference to the data after the update.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">It&#8217;s a common approach when working with functional programming and if you want to understand some concepts of functional programming I recommend you read this <\/span><a href=\"https:\/\/dev.to\/helderburato\/understanding-concepts-of-functional-programming-with-javascript-2g1d\"><span style=\"font-weight: 400;\">article<\/span><\/a><span style=\"font-weight: 400;\"> I wrote some time ago.<\/span><\/p>\n<p><!--more--><\/p>\n<h2><span style=\"font-weight: 400;\">Why Avoid Mutation<\/span><\/h2>\n<p><span style=\"font-weight: 400;\">When you work with immutable data you can have some positive impacts like the following:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; Tracking data without mutation is much better;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">&#8211; Immutable states help you implement unidirectional data flow that helps you handle data;<\/span><\/p>\n<p><span style=\"font-weight: 400;\">I really recommend you read this <\/span><a href=\"https:\/\/alistapart.com\/article\/why-mutation-can-be-scary\/\"><span style=\"font-weight: 400;\">article<\/span><\/a><span style=\"font-weight: 400;\"> to go deeper into why avoid mutation.<\/span><\/p>\n<h2>Causing Mutation<\/h2>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6695\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2020\/04\/mutation.jpg\" alt=\"\" width=\"2108\" height=\"962\" srcset=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2020\/04\/mutation.jpg 2108w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2020\/04\/mutation-768x350.jpg 768w\" sizes=\"(max-width: 2108px) 100vw, 2108px\" \/><\/p>\n<p><span style=\"font-weight: 400;\">The following steps will cause mutation into the array when adding, removing and editing elements from `family`.<\/span><\/p>\n<p>To show an example of mutating, we&#8217;ll use the following array:<\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">const heroesMutate = ['Spider-man', 'Thor', 'Hulk', 'Iron Man'];\nconsole.log(heroesMutate); \/\/ =&gt; [\"Spider-man\", \"Thor\", \"Hulk\", \"Iron Man\"]\n<\/code><\/pre>\n<h3>Including in Array<\/h3>\n<p>Methods that will be used:<\/p>\n<ul>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/pt-PT\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/push\"><span style=\"font-weight: 400;\">Array.prototype.push()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/pt-PT\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/unshift\"><span style=\"font-weight: 400;\">Array.prototype.unshift()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/pt-PT\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/splice\"><span style=\"font-weight: 400;\">Array.prototype.splice()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">See the following use-case examples for these methods:<\/span><\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">\nheroesMutate.push('Captain Marvel');\nconsole.log(heroesMutate); \/\/ =&gt; [\"Spider-man\", \"Thor\", \"Hulk\", \"Iron Man\", \"Captain Marvel\"]\n\nheroesMutate.unshift('Deadpool');\nconsole.log(heroesMutate); \/\/ =&gt; [\"Deadpool\", \"Spider-man\", \"Thor\", \"Hulk\", \"Iron Man\", \"Captain Marvel\"]\n\nheroesMutate.splice(2, 0, 'Black Panther');\nconsole.log(heroesMutate); \/\/ =&gt; [\"Deadpool\", \"Spider-man\", \"Black Panther\", \"Thor\", \"Hulk\", \"Iron Man\", \"Captain Marvel\"]\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>Editing the Array<\/h3>\n<p><span style=\"font-weight: 400;\">The following case will find index for the element we want to edit and set value to the index found:<\/span><\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">\nconst indexDeadpool = heroesMutate.indexOf('Deadpool');\nheroesMutate[indexDeadpool] = 'Wolverine';\n\nconsole.log(heroesMutate); \/\/ =&gt; [\"Wolverine\", \"Spider-man\", \"Black Panther\", \"Thor\", \"Hulk\", \"Iron Man\", \"Captain Marvel\"]\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>Removing in the Array<\/h3>\n<p><span style=\"font-weight: 400;\">Methods that will be used:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/pop\"><span style=\"font-weight: 400;\">Array.prototype.pop()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/shift\"><span style=\"font-weight: 400;\">Array.prototype.shift()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/pt-PT\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/splice\"><span style=\"font-weight: 400;\">Array.prototype.splice()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">See the following use-case examples for these methods:<\/span><\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">\nheroesMutate.pop();\nconsole.log(heroesMutate); \/\/ =&gt; [\"Wolverine\", \"Spider-man\", \"Black Panther\", \"Thor\", \"Hulk\", \"Iron Man\"]\n\nheroesMutate.shift();\nconsole.log(heroesMutate); \/\/ =&gt; [\"Spider-man\", \"Black Panther\", \"Thor\", \"Hulk\", \"Iron Man\"]\n\nheroesMutate.splice(1, 1);\nconsole.log(heroesMutate); \/\/ =&gt; [\"Spider-man\", \"Thor\", \"Hulk\", \"Iron Man\"]\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h2>Avoiding Mutation<\/h2>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-6694\" src=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2020\/04\/without-mutation.jpg\" alt=\"\" width=\"2108\" height=\"962\" srcset=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2020\/04\/without-mutation.jpg 2108w, https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2020\/04\/without-mutation-768x350.jpg 768w\" sizes=\"(max-width: 2108px) 100vw, 2108px\" \/><\/p>\n<p>In this topic, we&#8217;ll add, remove and edit, avoiding mutations.<\/p>\n<p><span style=\"font-weight: 400;\">Methods that will be used:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/slice\"><span style=\"font-weight: 400;\">Array.prototype.slice()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/concat\"><span style=\"font-weight: 400;\">Array.prototype.concat()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/pt-BR\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/map\"><span style=\"font-weight: 400;\">Array.prototype.map()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/pt-BR\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\/filtro\"><span style=\"font-weight: 400;\">Array.prototype.filter()<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Operators\/Spread_syntax\"><span style=\"font-weight: 400;\">Spread syntax<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">See the following use-cases:<\/span><\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">\nconst villains = ['Loki', 'Thanos', 'Venom', 'Abomination'];\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>Including in the Array<\/h3>\n<p><span style=\"font-weight: 400;\">Add to the end of array:<\/span><\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">\nconst newVillains = villains.concat('Juggernaut');\nconst newVillains2 = [...newVillains, 'Magneto'];\nconst newVillains3 = ['Red Skull', ...newVillains2];\n\nconsole.log(villains); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Venom\", \"Abomination\"]\nconsole.log(newVillains); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Venom\", \"Abomination\", \"Juggernaut\"]\nconsole.log(newVillains2); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Venom\", \"Abomination\", \"Juggernaut\", \"Magneto\"]\nconsole.log(newVillains3); \/\/ =&gt; [\"Red Skull\", \"Loki\", \"Thanos\", \"Venom\", \"Abomination\", \"Juggernaut\", \"Magneto\"]\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p><span style=\"font-weight: 400;\">In the following example we&#8217;ll add <\/span><b>Ultron<\/b><span style=\"font-weight: 400;\">&nbsp; after <\/span><b>Thanos<\/b><span style=\"font-weight: 400;\"> in the array:<\/span><\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">\nconst newVillains = [...villains.slice(0, 2), 'Ultron', ...villains.slice(2, villains.length)];\n\nconsole.log(villains); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Venom\", \"Abomination\"]\nconsole.log(newVillains); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Ultron\", \"Venom\", \"Abomination\"]\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>Editing the Array<\/h3>\n<p><span style=\"font-weight: 400;\">In the following example we&#8217;ll edit `Venom` to `Galactus`:<\/span><\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">\nconst indexVenom = villains.indexOf('Venom');\nconst newVillains = [...villains.slice(0, indexVenom), 'Galactus', ...villains.slice(indexVenom+1)];\nconst newVillains2 = newVillains.map(v =&gt; v === 'Abomination' ? 'Ultron' : v);\n\nconsole.log(villains); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Venom\", \"Abomination\"]\nconsole.log(newVillains); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Galactus\", \"Abomination\"]\nconsole.log(newVillains2); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Galactus\", \"Ultron\"]\n<\/code><\/pre>\n<p>&nbsp;<\/p>\n<h3>Removing in the Array<\/h3>\n<p><span style=\"font-weight: 400;\">In the following example we&#8217;ll remove <\/span><b>Thanos<\/b><span style=\"font-weight: 400;\"> from the array:<\/span><\/p>\n<pre class=\"language-swift\"><code class=\"language-swift\">\nconst indexThanos = villains.indexOf('Thanos');\nconst newVillains = [...villains.slice(0, indexHelder), ...villains.slice(indexHelder+1)];\nconst newVillains2 = newVillains.filter(v =&gt; v !== 'Thanos');\n\nconsole.log(villains); \/\/ =&gt; [\"Loki\", \"Thanos\", \"Venom\", \"Abomination\"]\nconsole.log(newVillains); \/\/ =&gt; [\"Loki\", \"Venom\", \"Abomination\"]\nconsole.log(newVillains2); \/\/ =&gt; [\"Loki\", \"Abomination\"]\n<\/code><\/pre>\n<p>See that in all the examples that we developed above, a new instance of the array was created, thus avoiding the mutation of the initially defined arrays.<\/p>\n<p>&nbsp;<\/p>\n<h2>Wrapping Up<\/h2>\n<p>Avoiding mutations is a safe and one-way path.<\/p>\n<p><span style=\"font-weight: 400;\">When you realize that you&#8217;re writing code observing this type of detail, believe me, you will be writing better, secure code and avoiding possible bugs due to mutation.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Feel free to share your feedback and experience in the comments.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Enjoy programming! \u2728<\/span><\/p>\n<h2><span style=\"font-weight: 400;\">References<\/span><\/h2>\n<ul>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/developer.mozilla.org\/pt-PT\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Array\"><span style=\"font-weight: 400;\">Array &#8211; JavaScript | MDN<\/span><\/a><span style=\"font-weight: 400;\">;<\/span><\/li>\n<li style=\"font-weight: 400;\"><a href=\"https:\/\/www.marvel.com\/teams-and-groups\">Marvel Teams, Groups, Squads, &amp; Alliances<\/a>;<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Originally posted on dev.to In this article, I&#8217;ll focus on showing how to add, edit and remove items in an array causing mutation and non-mutation ways. One thing we need to keep in mind when writing code avoiding mutation is to return a new reference to the data after the update. It&#8217;s a common approach [&hellip;]<\/p>\n","protected":false},"author":65,"featured_media":9530,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[471],"tags":[1151,1152],"class_list":["post-6715","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-engenharia","tag-tag-frontend-br","tag-tag-javascript-br"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Avoid Array Mutation | Cheesecake Labs<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"pt_BR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Avoid Array Mutation | Cheesecake Labs\" \/>\n<meta property=\"og:description\" content=\"Originally posted on dev.to In this article, I&#8217;ll focus on showing how to add, edit and remove items in an array causing mutation and non-mutation ways. One thing we need to keep in mind when writing code avoiding mutation is to return a new reference to the data after the update. It&#8217;s a common approach [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/\" \/>\n<meta property=\"og:site_name\" content=\"Cheesecake Labs\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cheesecakelabs\" \/>\n<meta property=\"article:published_time\" content=\"2020-04-14T14:59:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-07-01T17:09:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2020\/04\/avoid_mutation.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2000\" \/>\n\t<meta property=\"og:image:height\" content=\"720\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Cheesecake Labs\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:site\" content=\"@cheesecakelabs\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. tempo de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/\",\"url\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/\",\"name\":\"How to Avoid Array Mutation | Cheesecake Labs\",\"isPartOf\":{\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/#website\"},\"datePublished\":\"2020-04-14T14:59:36+00:00\",\"dateModified\":\"2022-07-01T17:09:14+00:00\",\"author\":{\"@type\":\"person\",\"name\":\"Helder Burato Berto\"},\"breadcrumb\":{\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/#breadcrumb\"},\"inLanguage\":\"pt-BR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Avoid Array Mutation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/#website\",\"url\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/\",\"name\":\"Cheesecake Labs\",\"description\":\"Empresa de desenvolvimento e design de aplicativos mobile &amp; web que est\u00e1 reinventando o desenvolvimento de produtos com times remotos. N\u00f3s desenvolvemos aplicativos iOS, Android e aplica\u00e7\u00f5es Web com as melhores empresas dos EUA, do Brasil e do mundo.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"pt-BR\"},{\"@type\":\"Person\",\"name\":\"Helder Burato Berto\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-BR\",\"@id\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/#\/schema\/person\/image\/\",\"url\":false,\"contentUrl\":false,\"caption\":\"Helder Burato Berto\"},\"description\":\"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.\",\"url\":\"https:\/\/blog-stg.cheesecakelabs.com\/br\/\/autor\/helder-burato-berto\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Avoid Array Mutation | Cheesecake Labs","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"pt_BR","og_type":"article","og_title":"How to Avoid Array Mutation | Cheesecake Labs","og_description":"Originally posted on dev.to In this article, I&#8217;ll focus on showing how to add, edit and remove items in an array causing mutation and non-mutation ways. One thing we need to keep in mind when writing code avoiding mutation is to return a new reference to the data after the update. It&#8217;s a common approach [&hellip;]","og_url":"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/","og_site_name":"Cheesecake Labs","article_publisher":"https:\/\/www.facebook.com\/cheesecakelabs","article_published_time":"2020-04-14T14:59:36+00:00","article_modified_time":"2022-07-01T17:09:14+00:00","og_image":[{"width":2000,"height":720,"url":"https:\/\/ckl-website-static.s3.amazonaws.com\/wp-content\/uploads\/2020\/04\/avoid_mutation.png","type":"image\/png"}],"author":"Cheesecake Labs","twitter_card":"summary_large_image","twitter_creator":"@cheesecakelabs","twitter_site":"@cheesecakelabs","twitter_misc":{"Escrito por":null,"Est. tempo de leitura":"4 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/","url":"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/","name":"How to Avoid Array Mutation | Cheesecake Labs","isPartOf":{"@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/#website"},"datePublished":"2020-04-14T14:59:36+00:00","dateModified":"2022-07-01T17:09:14+00:00","author":{"@type":"person","name":"Helder Burato Berto"},"breadcrumb":{"@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/#breadcrumb"},"inLanguage":"pt-BR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/avoid-array-mutation\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/blog-stg.cheesecakelabs.com\/br\/"},{"@type":"ListItem","position":2,"name":"How to Avoid Array Mutation"}]},{"@type":"WebSite","@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/#website","url":"https:\/\/blog-stg.cheesecakelabs.com\/br\/","name":"Cheesecake Labs","description":"Empresa de desenvolvimento e design de aplicativos mobile &amp; web que est\u00e1 reinventando o desenvolvimento de produtos com times remotos. N\u00f3s desenvolvemos aplicativos iOS, Android e aplica\u00e7\u00f5es Web com as melhores empresas dos EUA, do Brasil e do mundo.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/blog-stg.cheesecakelabs.com\/br\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"pt-BR"},{"@type":"Person","name":"Helder Burato Berto","image":{"@type":"ImageObject","inLanguage":"pt-BR","@id":"https:\/\/blog-stg.cheesecakelabs.com\/br\/#\/schema\/person\/image\/","url":false,"contentUrl":false,"caption":"Helder Burato Berto"},"description":"10 years of experience in Marketing and Sales in the Technology sector. My main purpose is help, support and structure efficient operations and also develop independent and multidisciplinary teams.","url":"https:\/\/blog-stg.cheesecakelabs.com\/br\/\/autor\/helder-burato-berto\/"}]}},"_links":{"self":[{"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/posts\/6715","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/users\/65"}],"replies":[{"embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/comments?post=6715"}],"version-history":[{"count":1,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/posts\/6715\/revisions"}],"predecessor-version":[{"id":10175,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/posts\/6715\/revisions\/10175"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/media\/9530"}],"wp:attachment":[{"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/media?parent=6715"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/categories?post=6715"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog-stg.cheesecakelabs.com\/br\/wp-json\/wp\/v2\/tags?post=6715"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}