<?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>let Archives - Artificial Intelligence</title>
	<atom:link href="https://www.aiuniverse.xyz/tag/let/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aiuniverse.xyz/tag/let/</link>
	<description>Exploring the universe of Intelligence</description>
	<lastBuildDate>Wed, 16 Mar 2022 05:43:32 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>JavaScript ES6 Features</title>
		<link>https://www.aiuniverse.xyz/javascript-es6-features/</link>
					<comments>https://www.aiuniverse.xyz/javascript-es6-features/#respond</comments>
		
		<dc:creator><![CDATA[dharmendra]]></dc:creator>
		<pubDate>Wed, 15 Sep 2021 13:08:56 +0000</pubDate>
				<category><![CDATA[ECMAScript]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Arrow]]></category>
		<category><![CDATA[const]]></category>
		<category><![CDATA[ES6]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[let]]></category>
		<category><![CDATA[variable]]></category>
		<guid isPermaLink="false">https://www.aiuniverse.xyz/?p=15542</guid>

					<description><![CDATA[<p>What is ECMAScript 6 (or ES6) ECMAScript 2015 (or ES6) is the sixth and major edition of the ECMAScript language specification standard. It defines the standard for <a class="read-more-link" href="https://www.aiuniverse.xyz/javascript-es6-features/">Read More</a></p>
<p>The post <a href="https://www.aiuniverse.xyz/javascript-es6-features/">JavaScript ES6 Features</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">What is ECMAScript 6 (or ES6)</h2>



<p>ECMAScript 2015 (or ES6) is the sixth and major edition of the ECMAScript language specification standard. It defines the standard for the JavaScript implementation.</p>



<p>ES6 brought significant changes to the JavaScript language. It introduces several new features such as, block-scoped variables, new loop for iterating over arrays and objects, template literals, and many other enhancements to make JavaScript programming easier and more fun. In this chapter, we will discuss some of the best ES6 features that you can use in your everyday JavaScript coding.</p>



<h2 class="wp-block-heading">The <code>let</code> Keyword</h2>



<p>ES6 introduces the new&nbsp;<code>let</code>&nbsp;keyword for declaring variables. Prior to ES6, the only way to declare a variable in JavaScript was the&nbsp;<code>var</code>&nbsp;keyword. Let&#8217;s see what&#8217;s the difference between them is.</p>



<p>There are two critical differences between the <code>var</code> and <code>let</code>. Variables declared with the <code>var</code> keyword are function-scoped and hoisted at the top within its scope, whereas variables declared with <code>let</code> keyword are block-scoped (<code>{}</code>) and they are not hoisted.</p>



<p>Block scoping simply means that a new scope is created between a pair of curly brackets i.e. <code>{}</code>. Therefore, if you declare a variable with the <code>let</code> keyword inside a loop, it does not exist outside of the loop, as demonstrated in the following example:</p>



<script src="https://gist.github.com/dharmu9898/5a457ed59ef28a2c53d1b490389f5fcd.js"></script>



<p>As you can see in the above example the variable <code>i</code> in the first block is not accessible outside the <code>for</code> loop. This also enables us to reuse the same variable name multiple times as its scope is limited to the block (<code>{}</code>), which results in less variable declaration and more cleaner code.</p>



<h2 class="wp-block-heading">The <code>const</code> Keyword</h2>



<p>The new <code>const</code> keyword makes it possible to define constants. Constants are read-only, you cannot reassign new values to them. They are also block-scoped like <code>let</code>.</p>



<script src="https://gist.github.com/dharmu9898/3d4892fbca0d717530063f3fcb8f46cb.js"></script>



<h4 class="wp-block-heading">However, you can still change object properties or array elements:</h4>



<script src="https://gist.github.com/dharmu9898/228612cb17194323de5e0d78c8182b6c.js"></script>



<h2 class="wp-block-heading">The <code>for...of</code> Loop Variable</h2>



<p>The new <code>for...of</code> loop allows us to iterate over arrays or other iterable objects very easily. Also, the code inside the loop is executed for each element of the iterable object. Here&#8217;s an example:</p>



<script src="https://gist.github.com/dharmu9898/7cb21e7cd519ce2f3a5887d7fc79d699.js"></script>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="1002" height="598" src="https://www.aiuniverse.xyz/wp-content/uploads/2021/09/variable.jpg" alt="" class="wp-image-15543" srcset="https://www.aiuniverse.xyz/wp-content/uploads/2021/09/variable.jpg 1002w, https://www.aiuniverse.xyz/wp-content/uploads/2021/09/variable-300x179.jpg 300w, https://www.aiuniverse.xyz/wp-content/uploads/2021/09/variable-768x458.jpg 768w" sizes="(max-width: 1002px) 100vw, 1002px" /></figure>



<h2 class="wp-block-heading">Arrow Functions</h2>



<p>Arrow Functions are another interesting feature in ES6. It provides a more concise syntax for writing function expressions by opting out the <code>function</code> and <code>return</code> keywords.</p>



<p>Arrow functions are defined using a new syntax, the fat arrow (<code>=></code>) notation. Let&#8217;s see how it looks:</p>



<script src="https://gist.github.com/dharmu9898/f6e80a211d876bf65335c1c4e3044e19.js"></script>



<figure class="wp-block-image size-full"><img decoding="async" width="1023" height="572" src="https://www.aiuniverse.xyz/wp-content/uploads/2021/09/arrow.jpg" alt="" class="wp-image-15544" srcset="https://www.aiuniverse.xyz/wp-content/uploads/2021/09/arrow.jpg 1023w, https://www.aiuniverse.xyz/wp-content/uploads/2021/09/arrow-300x168.jpg 300w, https://www.aiuniverse.xyz/wp-content/uploads/2021/09/arrow-768x429.jpg 768w" sizes="(max-width: 1023px) 100vw, 1023px" /></figure>
<p>The post <a href="https://www.aiuniverse.xyz/javascript-es6-features/">JavaScript ES6 Features</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.aiuniverse.xyz/javascript-es6-features/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
