{"id":4303,"date":"2022-03-04T07:27:18","date_gmt":"2022-03-04T07:27:18","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=4303"},"modified":"2022-03-04T07:27:19","modified_gmt":"2022-03-04T07:27:19","slug":"javascript-spread-operator","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2022\/03\/04\/javascript-spread-operator\/","title":{"rendered":"Javascript &#8211; Spread Operator"},"content":{"rendered":"\n<p><strong>OVERVIEW<\/strong><\/p>\n\n\n\n<p>The Spread operator is a little-known operator which allows you to join arrays together. This might sound similar to the join() function but the difference is that the join() function returns the array as a string, whereas the spread operator returns it as an array.<\/p>\n\n\n\n<p>The spread operator is represented by three dots &#8230;<\/p>\n\n\n\n<p>The sample code below shows it in action<\/p>\n\n\n\n<p><strong>SAMPLE CODE<\/strong><\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\n&lt;html&gt;\n\t&lt;head&gt;&lt;title&gt;Spread Operator&lt;\/title&gt;&lt;\/head&gt;\n\n\t&lt;script&gt;\n\t let arr1 = &#x5B;1,2,3];\n\t let arr2 = &#x5B;4.5,6.09,10.001];\n\t var arr3 = &#x5B;&quot;one&quot;, &quot;two&quot;, &quot;three&quot;];\n\n\t let arr4 = &#x5B;...arr1, ...arr2, ...arr3];\n\t document.write(arr4);\n\n\t&lt;\/script&gt;\n\t&lt;body&gt;\n\t&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre><\/div>\n\n\n<p>The output is shown below<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">1,2,3,4.5,6.09,10.001,one,two,three <\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>OVERVIEW The Spread operator is a little-known operator which allows you to join arrays together. This might sound similar to the join() function but the <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2022\/03\/04\/javascript-spread-operator\/\" title=\"Javascript &#8211; Spread Operator\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":2463,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-4303","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4303","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=4303"}],"version-history":[{"count":3,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4303\/revisions"}],"predecessor-version":[{"id":4306,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/4303\/revisions\/4306"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/2463"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=4303"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=4303"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=4303"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}