<?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/"
	
xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
>

<channel>
	<title>ES6 - Bipon's Diary</title>
	<atom:link href="https://biponnotes.iglyphic.com/tag/es6/feed/" rel="self" type="application/rss+xml" />
	<link>https://biponnotes.iglyphic.com</link>
	<description>Do good for others. It will come back in unexpected ways.</description>
	<lastBuildDate>Tue, 14 Jan 2020 08:30:10 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.9.10</generator>
<site xmlns="com-wordpress:feed-additions:1">168324471</site>	<item>
		<title>Filter</title>
		<link>https://biponnotes.iglyphic.com/filter/</link>
					<comments>https://biponnotes.iglyphic.com/filter/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Tue, 14 Jan 2020 08:28:12 +0000</pubDate>
				<category><![CDATA[ES6]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=364</guid>

					<description><![CDATA[<p>The filter is the same as the map, but if the function applied here returns true, then it will move to the new array, or if the function returns false then that item will not be in the array. Suppose I want to extract only the odd numbers from the following array and place them&#8230;<a href="https://biponnotes.iglyphic.com/filter/" class="more-link">Continue reading <span class="screen-reader-text">Filter</span></a></p>
<p>The post <a href="https://biponnotes.iglyphic.com/filter/">Filter</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>The filter is the same as the <code>map</code>, but if the function applied here returns <code>true</code>, then it will move to the new array, or if the function returns <code>false </code>then that item will not be in the array.<br> Suppose I want to extract only the odd numbers from the following array and place them in the new array:</p>



<p> <code>var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9] </code></p>



<p>Now, by applying a filter method, I can simplify it</p>



<pre class="wp-block-code"><code>var newArr = arr.filter(function(item) {
   return item % 2 == 0
})</code></pre>



<p>Functions are assigned to each <code>item</code>. And the one that returns <code>true </code>here is the new <code>array</code>. And the one that returns <code>false </code>is not in the new array.<br> You can also call here with an anonymous function or an external function, just like a map. View the Result:</p>



<p><code> newArr </code></p>



<figure class="wp-block-image"><img width="200" height="56" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/13.png?resize=200%2C56&#038;ssl=1" alt="" class="wp-image-365" data-recalc-dims="1"/></figure>



<p>The filter also accentuates <code>three arguments</code> on the map:</p>



<figure class="wp-block-image"><img loading="lazy" width="540" height="240" src="https://i1.wp.com/bipon.me/wp-content/uploads/2020/01/14.png?resize=540%2C240&#038;ssl=1" alt="" class="wp-image-366" srcset="https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/14.png?w=540&amp;ssl=1 540w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/14.png?resize=300%2C133&amp;ssl=1 300w" sizes="(max-width: 540px) 100vw, 540px" data-recalc-dims="1" /></figure>



<p>Using ES6 syntax</p>



<p><code> const newArr = arr.filter(item => item % 2 === 0); </code></p><p>The post <a href="https://biponnotes.iglyphic.com/filter/">Filter</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/filter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">364</post-id>	</item>
		<item>
		<title>Javascript ES6 &#8211; Map</title>
		<link>https://biponnotes.iglyphic.com/javascript-es6-map/</link>
					<comments>https://biponnotes.iglyphic.com/javascript-es6-map/#respond</comments>
		
		<dc:creator><![CDATA[bipon68]]></dc:creator>
		<pubDate>Fri, 10 Jan 2020 07:51:17 +0000</pubDate>
				<category><![CDATA[ES6]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[javascript]]></category>
		<guid isPermaLink="false">https://bipon.me/?p=328</guid>

					<description><![CDATA[<p>Javascript&#8217;s ES6 has nothing quite new in our eyes without syntax differences, or syntactic sugar.&#160;But this time we will discuss something completely new.&#160;Yes this thing has been added to ES6 completely new.&#160;It never existed in any previous version of JavaScript.&#160;That&#8217;s the map&#160;Map. Do not mistake&#160;this map&#160;Mapas a map&#160;map.&#160;The reason&#160;mapis a method.&#160;But the map we&#160;Mapwill talk&#8230;<a href="https://biponnotes.iglyphic.com/javascript-es6-map/" class="more-link">Continue reading <span class="screen-reader-text">Javascript ES6 &#8211; Map</span></a></p>
<p>The post <a href="https://biponnotes.iglyphic.com/javascript-es6-map/">Javascript ES6 – Map</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>Javascript&#8217;s ES6 has nothing quite new in our eyes without syntax differences, or syntactic sugar.&nbsp;But this time we will discuss something completely new.&nbsp;Yes this thing has been added to ES6 completely new.&nbsp;It never existed in any previous version of JavaScript.&nbsp;That&#8217;s the map&nbsp;<code>Map</code>.</p>



<p>Do not mistake&nbsp;this map&nbsp;<code>Map</code>as a map&nbsp;<code>map</code>.&nbsp;The reason&nbsp;<code>map</code>is a method.&nbsp;But the map we&nbsp;<code>Map</code>will talk about&nbsp;here today&nbsp;is a data structure.&nbsp;The new introduction has been introduced to developers in the ES6 version of JavaScript.&nbsp;But this is a bit different from the object type data structure.&nbsp;It has its own method, its own properties.&nbsp;The map can also access all kinds of functions, booleans, integers, characters, strings.&nbsp;So we will discuss this in detail today.</p>



<h3 id="f564">Map (&nbsp;<code>Map)</code>create:</h3>



<p><strong>Taking a new map: If</strong>&nbsp;we want to take a new map data structure, we can take it like this:</p>



<p>  <code>const&nbsp;bName&nbsp;=&nbsp;new&nbsp;Map() </code></p>



<p> Diameter!&nbsp;There&nbsp;<code>bName</code>a map called.&nbsp;Now inside the map there are keys and values.&nbsp;If we want to put any new value inside this map: </p>



<p> <code>bName.set('fullName',&nbsp;'Bipon&nbsp;Biswas'); </code></p>



<p> Now if you want to access any data from the map, there is another method.&nbsp;Want to know&nbsp;<code>bName</code>&nbsp;<code>fullName</code> </p>



<p><code> bName.get('fullName') </code></p>



<figure class="wp-block-image"><img loading="lazy" width="624" height="138" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/1-2.png?resize=624%2C138&#038;ssl=1" alt="" class="wp-image-332" srcset="https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/1-2.png?w=624&amp;ssl=1 624w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/1-2.png?resize=300%2C66&amp;ssl=1 300w" sizes="(max-width: 624px) 100vw, 624px" data-recalc-dims="1" /></figure>



<p> Again we can also check if there is a specific value in our map: </p>



<p><code> bName.has('fullName'); </code></p>



<p> Since our map&nbsp;<code>fullName</code>is what it is, it will be true: </p>



<figure class="wp-block-image"><img loading="lazy" width="630" height="142" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/2-1.png?resize=630%2C142&#038;ssl=1" alt="" class="wp-image-335" srcset="https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/2-1.png?w=630&amp;ssl=1 630w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/2-1.png?resize=300%2C68&amp;ssl=1 300w" sizes="(max-width: 630px) 100vw, 630px" data-recalc-dims="1" /></figure>



<p> Now if that is not the case then it will be false: </p>



<p> <code>bName.has('something'); </code></p>



<figure class="wp-block-image"><img loading="lazy" width="674" height="180" src="https://i1.wp.com/bipon.me/wp-content/uploads/2020/01/3-1.png?resize=674%2C180&#038;ssl=1" alt="" class="wp-image-336" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/3-1.png?w=674&amp;ssl=1 674w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/3-1.png?resize=300%2C80&amp;ssl=1 300w" sizes="(max-width: 674px) 100vw, 674px" data-recalc-dims="1" /></figure>



<p> Now we can delete any such pair from the map if we want.&nbsp;First, we have not added another new pair: </p>



<p><code> bName.set('sajib',&nbsp;'biswas') </code></p>



<p> Now if you want to double check whether the new pair has been added to the map: </p>



<p> <code>bName.has('sajib'); </code></p>



<p> Now we want&nbsp;<code>sajib</code>delete&nbsp;this&nbsp;removal: </p>



<p> <code>bName.delete('sajib'); </code></p>



<p> Diameter!&nbsp;Deleted.&nbsp;Now if I check this is&nbsp;<code>sajib</code>there: </p>



<p> <code>bName.has('sajib'); </code></p>



<figure class="wp-block-image"><img loading="lazy" width="589" height="138" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/4-1.png?resize=589%2C138&#038;ssl=1" alt="" class="wp-image-337" srcset="https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/4-1.png?w=589&amp;ssl=1 589w, https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/4-1.png?resize=300%2C70&amp;ssl=1 300w" sizes="(max-width: 589px) 100vw, 589px" data-recalc-dims="1" /></figure>



<p> That would be a lie, because we&#8217;ve already deleted it from our map </p>



<figure class="wp-block-image"><img loading="lazy" width="753" height="208" src="https://i1.wp.com/bipon.me/wp-content/uploads/2020/01/5-1.png?resize=753%2C208&#038;ssl=1" alt="" class="wp-image-338" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/5-1.png?w=753&amp;ssl=1 753w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/5-1.png?resize=300%2C83&amp;ssl=1 300w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/5-1.png?resize=750%2C207&amp;ssl=1 750w" sizes="(max-width: 753px) 100vw, 753px" data-recalc-dims="1" /></figure>



<p> Now we&nbsp;<code>bName</code>can clear the&nbsp;entire&nbsp;map&nbsp;if we want&nbsp;: </p>



<p><code> bName.clear(); </code></p>



<p> Now if you check&nbsp;<code>bName</code>, nothing can be found inside: </p>



<p> <code>console.log(bName); </code></p>



<figure class="wp-block-image"><img loading="lazy" width="627" height="223" src="https://i0.wp.com/bipon.me/wp-content/uploads/2020/01/6-1.png?resize=627%2C223&#038;ssl=1" alt="" class="wp-image-339" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/6-1.png?w=627&amp;ssl=1 627w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/6-1.png?resize=300%2C107&amp;ssl=1 300w" sizes="(max-width: 627px) 100vw, 627px" data-recalc-dims="1" /></figure>



<p> Suppose we have a map like the following with a few elements: </p>



<p><code> const&nbsp;boxItem&nbsp;=&nbsp;new&nbsp;Map(); </code></p>



<p> Now put some elements inside it: </p>



<pre class="wp-block-code"><code>boxItem.set('name', 'Bipon Biswas');
boxItem.set('job', 'student');
boxItem.set('color', 'blue')
boxItem.set('os', 'windows')
boxItem.set('mobile', 'iOS')
boxItem.set('city', 'dhaka')</code></pre>



<p> Now you will find&nbsp;<code>boxItem</code> all the data inside&nbsp;this&nbsp;map: </p>



<p><code> console.log(boxItem); </code></p>



<figure class="wp-block-image"><img loading="lazy" width="1163" height="307" src="https://i1.wp.com/bipon.me/wp-content/uploads/2020/01/7.png?fit=1024%2C270&amp;ssl=1" alt="" class="wp-image-341" srcset="https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/7.png?w=1163&amp;ssl=1 1163w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/7.png?resize=300%2C79&amp;ssl=1 300w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/7.png?resize=768%2C203&amp;ssl=1 768w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/7.png?resize=1024%2C270&amp;ssl=1 1024w, https://i0.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/7.png?resize=750%2C198&amp;ssl=1 750w" sizes="(max-width: 1040px) 100vw, 1040px" /></figure>



<p> </p>



<p> If we want to know how many elements inside the map we can find the properties of the map&nbsp;<code>size</code>: Now we can also loop in the map if we want: </p>



<p> <code>console.log(boxItem.size); </code></p>



<figure class="wp-block-image"><img loading="lazy" width="756" height="160" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/8.png?resize=756%2C160&#038;ssl=1" alt="" class="wp-image-342" srcset="https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/8.png?w=756&amp;ssl=1 756w, https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/8.png?resize=300%2C63&amp;ssl=1 300w, https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/8.png?resize=750%2C159&amp;ssl=1 750w" sizes="(max-width: 756px) 100vw, 756px" data-recalc-dims="1" /></figure>



<pre class="wp-block-code"><code>boxItem.forEach((value, key) => console.log(`Key is: ${key} and the value is: ${value}`));</code></pre>



<p><code>forEach</code>&nbsp;In the second argument in the method, we usually get the index but here in the case of the map we get the key of the map: </p>



<figure class="wp-block-image"><img loading="lazy" width="761" height="231" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/9.png?resize=761%2C231&#038;ssl=1" alt="" class="wp-image-343" srcset="https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/9.png?w=761&amp;ssl=1 761w, https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/9.png?resize=300%2C91&amp;ssl=1 300w, https://i2.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/9.png?resize=750%2C228&amp;ssl=1 750w" sizes="(max-width: 761px) 100vw, 761px" data-recalc-dims="1" /></figure>



<p> Likewise, we can&nbsp;<code>for…of</code>also run a loop: </p>



<pre class="wp-block-code"><code>for(let [key, value] of favorite.entries()) {
   console.log(`Key is: ${key} and the value is: ${value}`);
}</code></pre>



<figure class="wp-block-image"><img loading="lazy" width="762" height="222" src="https://i2.wp.com/bipon.me/wp-content/uploads/2020/01/10.png?resize=762%2C222&#038;ssl=1" alt="" class="wp-image-344" srcset="https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/10.png?w=762&amp;ssl=1 762w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/10.png?resize=300%2C87&amp;ssl=1 300w, https://i1.wp.com/biponnotes.iglyphic.com/wp-content/uploads/2020/01/10.png?resize=750%2C219&amp;ssl=1 750w" sizes="(max-width: 762px) 100vw, 762px" data-recalc-dims="1" /></figure>



<p> <strong>Note</strong>: One of the important differences is also that you’re able to use anything for the keys. You’re not just limited to primitive values like symbols, numbers, or strings, but you can even use functions, objects and dates – too. Keys won’t be casted to strings like with regular objects, either.</p>



<pre class="wp-block-code"><code>var map = new Map()
map.set(new Date(), function today () {})
map.set(() => 'key', { pony: 'foo' })
map.set(Symbol('items'), [1, 2])</code></pre>



<p>This is how we can use the newly introduced map in JavaScript ES6. Now, is there more to it than other data structures? Yes this is</p>



<p>In the Map Data Structure:</p>



<p>1.&nbsp;We can easily run the loop.</p>



<p>2.&nbsp;We can find out the size of the map</p>



<p>3. Finally, it is much easier to insert or delete data from the map.</p>



<p><strong><a href="https://ponyfoo.com/articles/es6-maps-in-depth">Reference Source</a></strong></p><p>The post <a href="https://biponnotes.iglyphic.com/javascript-es6-map/">Javascript ES6 – Map</a> first appeared on <a href="https://biponnotes.iglyphic.com">Bipon's Diary</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://biponnotes.iglyphic.com/javascript-es6-map/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">328</post-id>	</item>
	</channel>
</rss>
