<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>es6 &#8211; Best DevOps</title>
	<atom:link href="https://www.bestdevops.com/tag/es6/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.bestdevops.com</link>
	<description>Lets Learn, Do it &#38; Share! Thats a Best DevOps!!!</description>
	<lastBuildDate>Tue, 24 Aug 2021 13:00:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.3</generator>
	<item>
		<title>Array map() Method In JavaScript</title>
		<link>https://www.bestdevops.com/array-map-method-in-javascript/</link>
		
		<dc:creator><![CDATA[pradeep]]></dc:creator>
		<pubDate>Tue, 24 Aug 2021 13:00:20 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[es6]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[map]]></category>
		<guid isPermaLink="false">https://www.bestdevops.com/?p=19692</guid>

					<description><![CDATA[The map() method in JavaScript creates an array by calling a specific function on each element present in the parent array. It [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h3 class="wp-block-heading">The <strong>map()</strong> method in JavaScript creates an array by calling a specific function on each element present in the parent array. It is a non-mutating method. Generally <strong>map()</strong> method is used to iterate over an array and calling function on every element of array.</h3>



<h3 class="wp-block-heading"><br><strong>Syntax:</strong></h3>



<pre class="wp-block-preformatted">array.map(function(currentValue, index, arr), thisValue)</pre>



<p class="wp-block-paragraph"><strong>Parameters:</strong>&nbsp;This method accepts two parameters as mentioned above and described below:</p>



<ul class="wp-block-list"><li><strong>function(currentValue, index, arr):</strong>&nbsp;It is required parameter and it runs on each element of array. It contains three parameters which are listed below:<ul><li><strong>currentValue:</strong>&nbsp;It is required parameter and it holds the value of current element.</li><li><strong>index:</strong>&nbsp;It is optional parameter and it holds the index of current element.</li><li><strong>arr:</strong>&nbsp;It is optional parameter and it holds the array.</li></ul></li><li><strong>thisValue:</strong>&nbsp;It is optional parameter and used to hold the value of passed to the function.</li></ul>



<p class="wp-block-paragraph"><strong>Return Value:</strong>&nbsp;It returns a new array and elements of arrays are result of callback function.</p>



<p class="wp-block-paragraph">Below examples illustrate the use of array map() method in JavaScript:<br><strong>Example 1:</strong> This example use array map() method and return the square of array element.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Output:</strong><br><img fetchpriority="high" decoding="async" width="300" height="248" src="https://media.geeksforgeeks.org/wp-content/uploads/20190306001953/map1-300x248.jpg" alt=""></p>



<p class="wp-block-paragraph"><strong>Example 2:</strong></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1369" height="750" src="https://www.bestdevops.com/wp-content/uploads/2021/08/image-121-edited.png" alt="" class="wp-image-19694" srcset="https://www.bestdevops.com/wp-content/uploads/2021/08/image-121-edited.png 1369w, https://www.bestdevops.com/wp-content/uploads/2021/08/image-121-edited-300x164.png 300w, https://www.bestdevops.com/wp-content/uploads/2021/08/image-121-edited-1024x561.png 1024w, https://www.bestdevops.com/wp-content/uploads/2021/08/image-121-edited-768x421.png 768w" sizes="(max-width: 1369px) 100vw, 1369px" /></figure>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>What is Spread syntax (&#8230;) in JavaScript ?</title>
		<link>https://www.bestdevops.com/what-is-spread-syntax-in-javascript/</link>
		
		<dc:creator><![CDATA[pradeep]]></dc:creator>
		<pubDate>Tue, 24 Aug 2021 12:05:14 +0000</pubDate>
				<category><![CDATA[DevOps]]></category>
		<category><![CDATA[es6]]></category>
		<category><![CDATA[JavaScript]]></category>
		<guid isPermaLink="false">https://www.bestdevops.com/?p=19681</guid>

					<description><![CDATA[pread syntax (...) allows an iterable such as an array expression or string to be expanded in places where zero or [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph"></p>



<h3 class="wp-block-heading"><strong>pread syntax</strong> (<code>...</code>) allows an iterable such as an array expression or string to be expanded in places where zero or more arguments (for function calls) or elements (for array literals) are expected, or an object expression to be expanded in places where zero or more key-value pairs (for object literals) are expected.</h3>



<h2 class="wp-block-heading" id="60dd">The Spread Syntax</h2>



<ul class="wp-block-list"><li>The spread syntax is simply three dots:&nbsp;<code>...</code></li><li><strong>It allows an iterable to expand in places where 0+ arguments are expected.</strong></li></ul>



<p class="wp-block-paragraph" id="7b2b">Definitions are tough without context. Lets explore some different use cases to help understand what this means.</p>



<h2 class="wp-block-heading">Example #</h2>



<p class="wp-block-paragraph">See the following <code>compare()</code> function compares two numbers:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">compare</span>(<span class="hljs-params">a, b</span>) </span>{
    <span class="hljs-keyword">return</span> a - b;
}</code></span></pre>


<p class="wp-block-paragraph">In ES5, to pass an array of two numbers to the <code>compare()</code> function, you often use the <code>apply()</code> method as follows:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript"><span class="hljs-keyword">var</span> result = compare.apply(<span class="hljs-literal">null</span>, &#91;<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]);
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// -1</span></code></span></pre>


<p class="wp-block-paragraph">However, by using the spread operator, you can pass an array of two numbers to the <code>compare()</code> function:</p>


<pre class="wp-block-code"><span><code class="hljs language-javascript"><span class="hljs-keyword">let</span> result = compare(...&#91;<span class="hljs-number">1</span>, <span class="hljs-number">2</span>]);
<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">// -1</span></code></span></pre>


<h2 class="wp-block-heading" id="description">Description</h2>



<p class="wp-block-paragraph">Spread syntax can be used when all elements from an object or array need to be included in a list of some kind.</p>



<p class="wp-block-paragraph">In the above example, the defined function takes&nbsp;<code>x</code>,&nbsp;<code>y</code>, and&nbsp;<code>z</code>&nbsp;as arguments and returns the sum of these values. An array value is also defined.</p>



<p class="wp-block-paragraph">When we invoke the function, we pass it all the values in the array using the spread syntax and the array name —&nbsp;<code>...numbers</code>.</p>



<p class="wp-block-paragraph">If the array contained more than three numbers, e.g. <code>[1, 2, 3, 4]</code>, then it would still work fine, except that all four would be passed, but only the first three would be used unless you added more arguments to the function, e.g.:</p>



<script src="https://gist.github.com/pradeeprjth/8d6778c1330d1829983247b21fb40f3e.js"></script>



<p class="wp-block-paragraph">Thankyou </p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
