<?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[ es8 - 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[ es8 - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Sun, 24 May 2026 16:31:22 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/es8/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ ES8: What’s new in the JavaScript language in 2017 ]]>
                </title>
                <description>
                    <![CDATA[ By Flavio H. Freitas ES8 is live! Released earlier this summer, ES8 (also called ES2017) offers new ways of coding with JavaScript. Let's explore them. If you have the latest version of Chrome, open the console and let's code together. How to access... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/es8-the-new-features-of-javascript-7506210a1a22/</link>
                <guid isPermaLink="false">66c349d0a7aea9fc97bdfb16</guid>
                
                    <category>
                        <![CDATA[ es8 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ software development ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 15 Jul 2017 08:54:55 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*9yuM4oWXT1Wfo0Cx5jkMwA.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Flavio H. Freitas</p>
<p>ES8 is live! Released earlier this summer, ES8 (also called ES2017) offers new ways of coding with JavaScript. Let's explore them.</p>
<p>If you have the latest version of Chrome, open the console and let's code together.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/IA-BH2UVyy--TrnW3x4zwQuxEMfW47VTVb5F" alt="Image" width="676" height="322" loading="lazy"></p>
<p><em>How to access the JavaScript console in Chrome: View &gt; Developer &gt; JavaScript Console</em></p>
<h2 id="heading-objectvalues">Object.values()</h2>
<p>Access all the values of our object without any complication. Here’s an example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> countries = {
    <span class="hljs-attr">BR</span>: <span class="hljs-string">'Brazil'</span>,
    <span class="hljs-attr">DE</span>: <span class="hljs-string">'Germany'</span>,
    <span class="hljs-attr">RO</span>: <span class="hljs-string">'Romania'</span>,
    <span class="hljs-attr">US</span>: <span class="hljs-string">'United States of America'</span>
};

<span class="hljs-built_in">Object</span>.values(countries); <span class="hljs-comment">// ['Brazil', 'Germany', 'Romania', 'United States of America']</span>
</code></pre>
<h2 id="heading-objectentries">Object.entries()</h2>
<p>Turn your <strong>object</strong> attribute in an <strong>array</strong> of attributes:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> countries = {
    <span class="hljs-attr">BR</span>: <span class="hljs-string">'Brazil'</span>,
    <span class="hljs-attr">DE</span>: <span class="hljs-string">'Germany'</span>,
    <span class="hljs-attr">RO</span>: <span class="hljs-string">'Romania'</span>,
    <span class="hljs-attr">US</span>: <span class="hljs-string">'United States of America'</span>
};

<span class="hljs-built_in">Object</span>.entries(countries); 
<span class="hljs-comment">// [['BR', 'Brazil'], ['DE', 'Germany'], ['RO', 'Romania'], ['US','United States of America']]</span>
</code></pre>
<h2 id="heading-string-padding-padstart-and-padend">String padding (padStart and padEnd)</h2>
<p>This returns the passed string adding the pad and the beginning or in the end of it. The function definition is:</p>
<pre><code class="lang-javascript"><span class="hljs-string">'string'</span>.padStart(targetLength, padString)
<span class="hljs-string">'string'</span>.padEnd(targetLength, padString)
</code></pre>
<p>We can make:</p>
<pre><code class="lang-javascript"><span class="hljs-string">'0.10'</span>.padStart(<span class="hljs-number">10</span>); <span class="hljs-comment">// it return a string of length 10, padding empty spaces in the beginning</span>
<span class="hljs-string">'hi'</span>.padStart(<span class="hljs-number">1</span>);            <span class="hljs-comment">// 'hi'</span>
<span class="hljs-string">'hi'</span>.padStart(<span class="hljs-number">5</span>);            <span class="hljs-comment">// '   hi'</span>
<span class="hljs-string">'hi'</span>.padStart(<span class="hljs-number">5</span>, <span class="hljs-string">'abcd'</span>);    <span class="hljs-comment">// 'abchi'</span>
<span class="hljs-string">'hi'</span>.padStart(<span class="hljs-number">10</span>, <span class="hljs-string">'abcd'</span>);   <span class="hljs-comment">// 'abcdabcdhi'</span>
<span class="hljs-string">'loading'</span>.padEnd(<span class="hljs-number">10</span>, <span class="hljs-string">'.'</span>);   <span class="hljs-comment">// 'loading...'</span>

<span class="hljs-comment">// useful example making things easier to read</span>
<span class="hljs-string">'0.10'</span>.padStart(<span class="hljs-number">12</span>);         <span class="hljs-comment">// '       0.10'</span>
<span class="hljs-string">'23.10'</span>.padStart(<span class="hljs-number">12</span>);        <span class="hljs-comment">// '      23.10'</span>
<span class="hljs-string">'12,330.10'</span>.padStart(<span class="hljs-number">12</span>);    <span class="hljs-comment">// '  12,330.10'</span>
</code></pre>
<h2 id="heading-objectgetownpropertydescriptors">Object.getOwnPropertyDescriptors()</h2>
<p>It returns all own (non-inherited) property descriptors of an object. The attributes of the return object can be: <code>value</code>, <code>writable</code>, <code>get</code>, <code>set</code>, <code>configurable</code> and <code>enumerable</code>.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> obj = {
    <span class="hljs-attr">name</span>: <span class="hljs-string">'Pablo'</span>,
    <span class="hljs-keyword">get</span> <span class="hljs-title">foo</span>() { <span class="hljs-keyword">return</span> <span class="hljs-number">42</span>; }
};

<span class="hljs-built_in">Object</span>.getOwnPropertyDescriptors(obj);
<span class="hljs-comment">//</span>
<span class="hljs-comment">// {</span>
<span class="hljs-comment">//  "name": {</span>
<span class="hljs-comment">//     "value": "Pablo",</span>
<span class="hljs-comment">//     "writable":true,</span>
<span class="hljs-comment">//     "enumerable":true,</span>
<span class="hljs-comment">//     "configurable":true</span>
<span class="hljs-comment">//  },</span>
<span class="hljs-comment">//  "foo":{</span>
<span class="hljs-comment">//     "enumerable":true,</span>
<span class="hljs-comment">//     "configurable":true,</span>
<span class="hljs-comment">//     "get": function foo()</span>
<span class="hljs-comment">//     "set": undefined</span>
<span class="hljs-comment">//  }</span>
<span class="hljs-comment">// }</span>
</code></pre>
<p>One practical example is: JavaScript has a method to copy properties <code>Object.assign()</code>. It copies the property whose key is <code>key</code>. Like this:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> value = source[key]; <span class="hljs-comment">// get</span>
target[key] = value;       <span class="hljs-comment">// set</span>
</code></pre>
<p>And in some cases it fails because it doesn't properly copy the properties with non-default attributes such as getters, setters and non-writable properties.</p>
<p>For example:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> objTarget = {};
<span class="hljs-keyword">const</span> objSource = {
    <span class="hljs-keyword">set</span> <span class="hljs-title">greet</span>(<span class="hljs-params">name</span>) { <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'hey, '</span> + name); }
};

<span class="hljs-built_in">Object</span>.assign(objTarget, objSource);
objTarget.greet = <span class="hljs-string">'love'</span>;     <span class="hljs-comment">// trying to set fails, sets greet = 'love'</span>
</code></pre>
<p>Solving:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> objTarget = {};
<span class="hljs-keyword">const</span> objSource = {
    <span class="hljs-keyword">set</span> <span class="hljs-title">greet</span>(<span class="hljs-params">name</span>) { <span class="hljs-built_in">console</span>.log(<span class="hljs-string">'hey, '</span> + name); }
};

<span class="hljs-built_in">Object</span>.defineProperties(objTarget,          
           <span class="hljs-built_in">Object</span>.getOwnPropertyDescriptors(objSource));

objTarget.greet = <span class="hljs-string">'love'</span>; <span class="hljs-comment">// prints 'hey, love'</span>
</code></pre>
<h2 id="heading-trailing-commas-in-function-parameter-lists-and-calls">Trailing commas in function parameter lists and calls</h2>
<p>This is a syntax change. It allows us to write a valid function declaration with comma in the end.</p>
<pre><code class="lang-javascript">getDescription(name, age,) { ... }
</code></pre>
<h2 id="heading-async-functions-async-and-await">Async functions (async and await)</h2>
<p>This makes it much easier to work with asynchronous functions:</p>
<pre><code class="lang-javascript"><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">loadExternalContent</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">new</span> <span class="hljs-built_in">Promise</span>(<span class="hljs-function">(<span class="hljs-params">resolve, reject</span>) =&gt;</span> {
        <span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {
            resolve(<span class="hljs-string">'hello'</span>);
        }, <span class="hljs-number">3000</span>);
    });
}

<span class="hljs-keyword">async</span> <span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">getContent</span>(<span class="hljs-params"></span>) </span>{
    <span class="hljs-keyword">const</span> text = <span class="hljs-keyword">await</span> loadExternalContent();
    <span class="hljs-built_in">console</span>.log(text);
}

<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'it will call function'</span>);
getContent();
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">'it called function'</span>);

<span class="hljs-comment">// it prints:</span>
<span class="hljs-string">'it will call function'</span> <span class="hljs-comment">// synchronous</span>
<span class="hljs-string">'it called function'</span>    <span class="hljs-comment">// synchronous</span>
<span class="hljs-string">'hello'</span>                 <span class="hljs-comment">// asynchronous (after 3 seconds)</span>
</code></pre>
<h2 id="heading-shared-memory-and-atomics">Shared memory and atomics</h2>
<p>According to the <a target="_blank" href="https://tc39.github.io/ecmascript_sharedmem/shmem.html">specification</a>:</p>
<blockquote>
<p>"Shared memory is being exposed in the form of a new SharedArrayBuffer type; The new global Atomics object provides atomic operations on shared memory locations, including operations that can be used to create blocking synchronization primitives."</p>
</blockquote>
<p>This means:</p>
<p>Shared memory: we can allow multiple threads read and write the same data with the new <code>SharedArrayBuffer</code> constructor.</p>
<p>Atomics: We can use the <code>Atomics</code> object to make sure nothing that is being written or read will be interrupted in the middle of the process. So the operations are finished before a the next one starts.</p>
<p>If you enjoyed this article, be sure to like it give me a lot of claps — it means the world to the writer ? And f<a target="_blank" href="https://medium.com/@flaviohfreitas">ollow me</a> if you want to read more articles about Culture, Technology and Startups.</p>
<p><strong>Flávio H. de Freitas</strong> is an Entrepreneur, Engineer, Tech lover, Dreamer and Traveler. Has worked as <strong>CTO</strong> in <strong>Brazil</strong>, <strong>Silicon Valley and Europe</strong>.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
