<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ es7 - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ es7 - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 25 May 2026 05:07:04 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/es7/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ The newest version of JavaScript only has 2 new features. Here’s how they work. ]]>
                </title>
                <description>
                    <![CDATA[ By Tiago Lopes Ferreira Let’s talk about the latest version of JavaScript: ECMAScript 2016 (more commonly known as ES7). ES7 brings two new features: Array.prototype.includes() and the new exponential operator: **. Array.prototype.includes() Gone are... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/why-could-es7-be-called-es2-4c5f094ccef7/</link>
                <guid isPermaLink="false">66c3668a139b845d61e84bd4</guid>
                
                    <category>
                        <![CDATA[ Exponential Operator ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Array Prototype Includes ]]>
                    </category>
                
                    <category>
                        <![CDATA[ es7 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 13 Oct 2017 06:42:34 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*4KuLQRBf9qZkEGUsFKZnJg.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Tiago Lopes Ferreira</p>
<p>Let’s talk about the latest version of JavaScript: ECMAScript 2016 (more commonly known as ES7). ES7 brings two new features: <code>Array.prototype.includes()</code> and the new exponential operator: <code>**</code>.</p>
<h3 id="heading-arrayprototypeincludes">Array.prototype.includes()</h3>
<p>Gone are the days where we used <code>.indexOf()</code> to know if an element <strong>existed</strong> in an array.</p>
<p>The key word is <strong><em>“exist.”</em></strong></p>
<p><code>.indexOf()</code> is fine if we want to know at which index a given element appears.</p>
<p>But if our goal is to know if a given element <strong>exists</strong> in an array, then <code>.indexOf()</code> is not the best option. And the reason is simple: When querying the existence of something we expect a boolean value, <strong>not a number</strong>.</p>
<p><code>Array.prototype.includes()</code> does exactly that. It determines if a given element exists in an array, returning <code>true</code> if it does, <code>false</code> otherwise.</p>
<h3 id="heading-into-the-specification">Into The Specification</h3>
<pre><code><span class="hljs-built_in">Array</span>.prototype.includes ( searchElement [ , fromIndex ] )
</code></pre><ul>
<li><code>searchElement</code> — the element to search for.</li>
<li><code>fromIndex</code> <em>(optional)</em> — the index from which to start to search.</li>
</ul>
<p>Diving into the <a target="_blank" href="https://www.ecma-international.org/ecma-262/7.0/">specification</a> feels like searching for power.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*4KuLQRBf9qZkEGUsFKZnJg.png" alt="Image" width="470" height="352" loading="lazy"></p>
<p>The specification says:</p>
<p>Let’s go step-by-step and try to understand the specification with examples.</p>
<ol>
<li>The difference here is the position of the element 4. Because our first example places 4 in the last position, includes will search the whole array. By specification <code>.includes()</code> returns immediately after finding the <code>searchElement</code>. This makes our second operation much faster.</li>
<li>The big difference with the <a target="_blank" href="https://www.ecma-international.org/ecma-262/7.0/#sec-samevaluezero">SameValueZero</a> algorithm versus the <a target="_blank" href="https://www.ecma-international.org/ecma-262/7.0/#sec-strict-equality-comparison">Strict Equality Comparison</a> (used by <code>.indexOf()</code>) is that it allows detecting the <strong>NaN</strong> elements.</li>
<li>It returns the boolean <code>true</code> when the element is found and <code>false</code> otherwise. No more indexes as result ?</li>
<li>As opposite to <code>.indexOf()</code>, <code>.includes()</code> does not skip missing array elements. Instead, it treats them as <strong>undefined</strong> values.</li>
</ol>
<p>Are you starting to feel the power?</p>
<p>We haven’t even touched <code>fromIndex</code>.</p>
<p>Let’s check the specification:</p>
<blockquote>
<p>The optional second argument <code>fromIndex</code> defaults to <code>0</code> (i.e. the whole array is searched). If it is greater than or equal to the length of the array, <strong>false</strong> is returned, i.e. the array will not be searched. If it is negative, it is used as the <strong>offset</strong> from the end of the array to compute <code>fromIndex</code>. If the computed index is less than <code>0</code>, the whole array will be searched.</p>
</blockquote>
<ol>
<li>If no <code>fromIndex</code> is provided them the default value of <code>0</code> is taken and the <strong>whole</strong> array is searched.</li>
<li><code>.includes()</code> immediately returns <strong>false</strong> when the value of <code>fromIndex</code> is bigger than array’s length.</li>
<li>When <code>fromIndex</code> is negative, then it’s value is calculated as <code>array.length — fromIndex</code>. This is particularly useful when searching on the last elements. For example, <code>fromIndex = -5</code> is the same as searching on the last 5 elements.</li>
<li>To avoid <code>.includes()</code> from breaking when the <code>fromIndex</code> calculated value is lower than 0, the whole array is searched. I would rather break ?</li>
</ol>
<p>OK — one last new feature…</p>
<h3 id="heading-the-exponential-operator"><code>The Exponential Operator (**)</code></h3>
<p>We’ve been waiting for the day we can play with exponential numbers like we play with addition, subtraction, multiplication, division.</p>
<p>Well, that day is here.</p>
<p>The operator <code>**</code> behaves exactly the same way as <code>Math.pow()</code>. It returns the result of raising the first operand to the power of the second (e.g. <code>x ** y</code>).</p>
<p>That’s it!</p>
<p>You now have the power of <strong>ES7</strong>! Use it well!</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*owhYyEq_wSRyPN_OuyQXPQ.gif" alt="Image" width="480" height="360" loading="lazy"></p>
<h3 id="heading-thanks-to">Thanks to ?</h3>
<ul>
<li><a target="_blank" href="http://2ality.com/2016/01/ecmascript-2016.html">2ality.com</a> by <a target="_blank" href="https://twitter.com/rauschma">Axel Rauschmayer</a></li>
<li><a target="_blank" href="https://www.ecma-international.org/ecma-262/7.0/">ECMAScript® 2016 Language Specification</a></li>
<li>To all <a target="_blank" href="https://www.youtube.com/watch?v=7yeA7a0uS3A">He-Man</a> fans</li>
<li><a target="_blank" href="https://medium.freecodecamp.org/">freeCodeCamp</a> for publishing ❤️</li>
</ul>
<p>Be sure to check out my articles on ES6:</p>
<p><a target="_blank" href="https://medium.freecodecamp.org/lets-explore-es6-generators-5e58ed23b0f1"><strong>Let’s explore ES6 Generators</strong></a><br><a target="_blank" href="https://medium.freecodecamp.org/lets-explore-es6-generators-5e58ed23b0f1">_Generators, aka, an implementation of iterables._medium.freecodecamp.org</a><a target="_blank" href="https://medium.freecodecamp.org/oh-yes-async-await-f54e5a079fc1"><strong>Oh Yes! Async / Await</strong></a><br><a target="_blank" href="https://medium.freecodecamp.org/oh-yes-async-await-f54e5a079fc1">_async / await is the new JavaScript syntax to declare an asynchronous function._medium.freecodecamp.org</a></p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Introducing the new features that ECMAScript 2016 (ES7) adds to JavaScript ]]>
                </title>
                <description>
                    <![CDATA[ By Sanket Meghani Since ECMAScript 2015 (also known as ES6) was released, it has introduced a huge set of new features. They include arrow functions, sets, maps, classes and destructuring, and much more. In many ways, ES2015 is almost like learning a... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/ecmascript-2016-es7-features-86903c5cab70/</link>
                <guid isPermaLink="false">66c349a6a7aea9fc97bdfb0b</guid>
                
                    <category>
                        <![CDATA[ ES6 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ es7 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Mon, 14 Aug 2017 16:10:59 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*UdGS7qrmIMueYfILnJJ6QA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Sanket Meghani</p>
<p>Since ECMAScript 2015 (also known as ES6) was released, it has introduced a huge set of new features. They include arrow functions, sets, maps, classes and destructuring, and much more. In many ways, ES2015 is almost like learning a new version of JavaScript.</p>
<p>Ecma Technical Committee 39 governs the ECMA specification. They decided to release a new version of ECMAScript every year starting in 2015. A yearly update means no more big releases like ES6.</p>
<p>ECMAScript 2016 introduced only two new features:</p>
<ul>
<li><p>Array.prototype.includes()</p>
</li>
<li><p>Exponentiation operator</p>
</li>
</ul>
<h3 id="heading-arrayprototypeincludes">Array.prototype.includes()</h3>
<p><code>Array.prototype.includes()</code> checks the array for the <code>value</code> passed as an <code>argument</code>. It returns <code>true</code> if the array contains the <code>value</code>, otherwise, it returns <code>false</code>.</p>
<p>Before, we needed to use <code>Array.prototype.indexOf()</code> to check if the given array contains an element or not.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>];

<span class="hljs-keyword">if</span>(numbers.indexOf(<span class="hljs-number">2</span>) !== <span class="hljs-number">-1</span>) {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Array contains value'</span>);
}
</code></pre>
<p>With ECMA2016, we can write:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">if</span> (numbers.includes(<span class="hljs-number">2</span>)) {
  <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'Array contains value'</span>);
}
</code></pre>
<p><code>Array.prototype.includes()</code> handles <code>NaN</code> better than <code>Array.prototype.indexOf()</code>. If the array contains <code>NaN</code>, then <code>indexOf()</code> does not return a correct index while searching for <code>NaN</code>.</p>
<p><code>Array.prototype.includes()</code> returns the correct value when searching for <code>NaN</code>.</p>
<p><code>NaN</code> is a property of the JavaScript global object and represents a value that is Not-a-Number. There are known quirks when <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NaN">comparing <code>NaN</code> to another value</a>. These are addressed in <code>Array.prototype.includes()</code>, but not in <code>Array.protoype.indexOf</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> numbers = [<span class="hljs-number">1</span>, <span class="hljs-number">2</span>, <span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-literal">NaN</span>];

<span class="hljs-built_in">console</span>.log(numbers.indexOf(<span class="hljs-literal">NaN</span>)); <span class="hljs-comment">//Prints -1</span>
<span class="hljs-built_in">console</span>.log(numbers.includes(<span class="hljs-literal">NaN</span>)); <span class="hljs-comment">//Prints true</span>
</code></pre>
<h3 id="heading-exponentiation-operator">Exponentiation Operator</h3>
<p>JavaScript already supports many arithmetic operators like <code>+, -, *</code> and more.</p>
<p>ECMAScript 2016 introduced the exponentiation operator, <code>**</code>.</p>
<p>It has the same purpose as <code>Math.pow()</code>. It returns the first argument raised to the power of the second argument.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">let</span> base = <span class="hljs-number">3</span>;
<span class="hljs-keyword">let</span> exponent = <span class="hljs-number">4</span>;
<span class="hljs-keyword">let</span> result = base**exponent;

<span class="hljs-built_in">console</span>.log(result); <span class="hljs-comment">//81</span>
</code></pre>
<h3 id="heading-conclusion">Conclusion</h3>
<p>New features introduced by ECMA2016 provide convenient alternatives to existing functionalities.</p>
<p>Looking ahead, ECMA2017 was finalized in June of this year. New features include <code>async/await</code>, <code>SharedArrayBuffer</code> and some useful methods to <code>Object.prototype</code>.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
