<?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[ ecmascript - 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[ ecmascript - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Mon, 25 May 2026 05:06:35 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/ecmascript/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ What's New in JavaScript in 2023 – Changes with Code Examples ]]>
                </title>
                <description>
                    <![CDATA[ By Nishant Kumar ECMAScript 2023, the 14th edition of the language, has some great changes that will make your programming life easier.  In this article, I'll go through each of the changes and explain why they're helpful. So let’s dive in and see so... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/the-biggest-changes-in-javascript-this-year/</link>
                <guid isPermaLink="false">66d46078b6b7f664236cbe1d</guid>
                
                    <category>
                        <![CDATA[ ecmascript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 29 Nov 2023 18:09:51 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2023/11/What-s-new.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Nishant Kumar</p>
<p>ECMAScript 2023, the 14th edition of the language, has some great changes that will make your programming life easier. </p>
<p>In this article, I'll go through each of the changes and explain why they're helpful. So let’s dive in and see some new methods we got as an early Christmas present.</p>
<h2 id="heading-objectgroupby">Object.groupBy</h2>
<p>Let’s say you have an array of objects and want to separate them based on a property value, type, or quantity.</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> inventory = [
  { <span class="hljs-attr">name</span>: <span class="hljs-string">"asparagus"</span>, <span class="hljs-attr">type</span>: <span class="hljs-string">"vegetables"</span>, <span class="hljs-attr">quantity</span>: <span class="hljs-number">5</span> },
  { <span class="hljs-attr">name</span>: <span class="hljs-string">"bananas"</span>, <span class="hljs-attr">type</span>: <span class="hljs-string">"fruit"</span>, <span class="hljs-attr">quantity</span>: <span class="hljs-number">0</span> },
  { <span class="hljs-attr">name</span>: <span class="hljs-string">"goat"</span>, <span class="hljs-attr">type</span>: <span class="hljs-string">"meat"</span>, <span class="hljs-attr">quantity</span>: <span class="hljs-number">23</span> },
  { <span class="hljs-attr">name</span>: <span class="hljs-string">"cherries"</span>, <span class="hljs-attr">type</span>: <span class="hljs-string">"fruit"</span>, <span class="hljs-attr">quantity</span>: <span class="hljs-number">5</span> },
  { <span class="hljs-attr">name</span>: <span class="hljs-string">"fish"</span>, <span class="hljs-attr">type</span>: <span class="hljs-string">"meat"</span>, <span class="hljs-attr">quantity</span>: <span class="hljs-number">22</span> },
];
</code></pre>
<p>We have a new method now called <code>GroupBy</code> that lets you do just that.</p>
<p>To use it, use <code>Object.groupBy</code> on any array with objects, and pass a function that returns the specific key by which you want to categorize.</p>
<p>Here, we are having an array of objects called <code>inventory</code>. And a <code>myCallback</code> function that is taking a quantity as a parameter and returning <code>ok</code> if the quantity is more than 5, or else returning <code>restock</code>.</p>
<p>We are passing the inventory array and the <code>myCallback</code> function to Object,groupBy so that it groups the items in the array by quantity.</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">myCallback</span>(<span class="hljs-params">{ quantity }</span>) </span>{
  <span class="hljs-keyword">return</span> quantity &gt; <span class="hljs-number">5</span> ? <span class="hljs-string">"ok"</span> : <span class="hljs-string">"restock"</span>;
}

<span class="hljs-keyword">const</span> result2 = <span class="hljs-built_in">Object</span>.groupBy(inventory, myCallback);
</code></pre><p>The result will be an object which contains the key which is the category and the specified data inside it.</p>
<pre><code>{
    <span class="hljs-string">"restock"</span>: [
        {
            <span class="hljs-string">"name"</span>: <span class="hljs-string">"asparagus"</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"vegetables"</span>,
            <span class="hljs-string">"quantity"</span>: <span class="hljs-number">5</span>
        },
        {
            <span class="hljs-string">"name"</span>: <span class="hljs-string">"bananas"</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"fruit"</span>,
            <span class="hljs-string">"quantity"</span>: <span class="hljs-number">0</span>
        },
        {
            <span class="hljs-string">"name"</span>: <span class="hljs-string">"cherries"</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"fruit"</span>,
            <span class="hljs-string">"quantity"</span>: <span class="hljs-number">5</span>
        }
    ],
    <span class="hljs-string">"ok"</span>: [
        {
            <span class="hljs-string">"name"</span>: <span class="hljs-string">"goat"</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"meat"</span>,
            <span class="hljs-string">"quantity"</span>: <span class="hljs-number">23</span>
        },
        {
            <span class="hljs-string">"name"</span>: <span class="hljs-string">"fish"</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"meat"</span>,
            <span class="hljs-string">"quantity"</span>: <span class="hljs-number">22</span>
        }
    ]
}
</code></pre><h2 id="heading-arraytosliced-arraytosorted-and-arraytoreversed">Array.toSliced(), Array.toSorted(), and Array.toReversed()</h2>
<p>When we use methods like <code>sort()</code>, <code>splice()</code>, and <code>reverse()</code>, they mutate the original array. This can sometimes be an issue.</p>
<p>But when using <code>toSpliced()</code>, <code>toSorted()</code>, and <code>toReversed()</code>, we can splice, sort, and reverse an array without mutating the source array. Here's how it works:</p>
<pre><code class="lang-javascript"><span class="hljs-keyword">const</span> numbers = [<span class="hljs-number">3</span>, <span class="hljs-number">4</span>, <span class="hljs-number">1</span>, <span class="hljs-number">5</span>, <span class="hljs-number">2</span>];

<span class="hljs-keyword">const</span> splicedNumbers = numbers.toSpliced(<span class="hljs-number">1</span>, <span class="hljs-number">1</span>);
<span class="hljs-keyword">const</span> sortedNumbers = numbers.toSorted();
<span class="hljs-keyword">const</span> reversedNumbers = numbers.toReversed();
</code></pre>
<p>In this example, we are using <code>toSpliced()</code> to splice the array, <code>toSort()</code> to sort the array, and <code>toReversed()</code> to reverse the array. They work just like regular splice, sort, and reverse but the catch is they will return a new array, and not mutate the original one.</p>
<h2 id="heading-findlast-and-findlastindex">findLast() and findLastIndex()</h2>
<p>Before ES14, if you wanted to find the last element or index in an array that satisfies some condition, you would have to reverse the array first.</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">findLastIndexByReversing</span>(<span class="hljs-params">arr, target</span>) </span>{
  <span class="hljs-keyword">const</span> reversedArray = arr.slice().reverse();
  <span class="hljs-keyword">const</span> reversedIndex = reversedArray.indexOf(target);

  <span class="hljs-keyword">if</span> (reversedIndex !== <span class="hljs-number">-1</span>) {
    <span class="hljs-keyword">const</span> lastIndex = arr.length - <span class="hljs-number">1</span> - reversedIndex;
    <span class="hljs-keyword">return</span> lastIndex;
  } <span class="hljs-keyword">else</span> {
    <span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>; 
  }
}
</code></pre><p>In this example, <code>findLastIndexByReversing</code> creates a reversed copy of the original array using <code>slice().reverse()</code>. Then, it uses <code>indexOf</code> to find the first occurrence of the target element in the reversed array. The function calculates the corresponding index in the original array by subtracting the reversed index from the total length of the array minus 1. This gives you the last index of the element in the original array.</p>
<p>Or you can use a for loop that starts from the end.</p>
<pre><code><span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">findLastIndex</span>(<span class="hljs-params">arr, target</span>) </span>{
  <span class="hljs-keyword">for</span> (<span class="hljs-keyword">let</span> i = arr.length - <span class="hljs-number">1</span>; i &gt;= <span class="hljs-number">0</span>; i--) {
    <span class="hljs-keyword">if</span> (arr[i] === target) {
      <span class="hljs-keyword">return</span> i;
    }
  }
  <span class="hljs-keyword">return</span> <span class="hljs-number">-1</span>;
}
</code></pre><p>In this example, the <code>findLastIndex</code> function takes an array <code>arr</code> and a target element <code>target</code>. It iterates over the array from the end <code>arr.length - 1</code> to the beginning <code>0</code>. If it finds the target element, it returns the index. If the element is not found, it returns -1.</p>
<p>But now, we have a method known as <code>lastIndexOf()</code> that will start from the end of the array and return the value of the first element that satisfies the condition.</p>
<pre><code><span class="hljs-keyword">const</span> fruits = [<span class="hljs-string">'apple'</span>, <span class="hljs-string">'banana'</span>, <span class="hljs-string">'orange'</span>, <span class="hljs-string">'banana'</span>, <span class="hljs-string">'kiwi'</span>];

<span class="hljs-keyword">const</span> lastIndex = fruits.lastIndexOf(<span class="hljs-string">'banana'</span>);
</code></pre><p>Here is the output: </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2023/11/Screenshot-2023-11-29-at-11.09.16-PM.png" alt="Image" width="600" height="400" loading="lazy">
<em>Output showing <code>3</code></em></p>
<h2 id="heading-wrapping-up">Wrapping Up</h2>
<p>These were the changes that were introduced in JavaScript as ECMAScript 2023.</p>
<p>Thanks for reading, and I will see you in the next tutorial.</p>
<p>If you wish to see a short video version of the article, you can check that out here: </p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/XSfJZyTKpdA" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Why JavaScript Is the Programming Language of the Future ]]>
                </title>
                <description>
                    <![CDATA[ By Mehul Mohan JavaScript was the first programming language I picked up. Well, I actually started with HTML and CSS. Just like many other web developers, going with JavaScript was a no-brainer. This is simply because it blends so well with HTML and ... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/future-of-javascript/</link>
                <guid isPermaLink="false">66d4604d8812486a37369d17</guid>
                
                    <category>
                        <![CDATA[ ecmascript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ General Programming ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Design ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Web Development ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Sat, 04 Apr 2020 16:40:11 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/04/jsposter.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Mehul Mohan</p>
<p>JavaScript was the first programming language I picked up. Well, I actually started with HTML and CSS. Just like many other web developers, going with JavaScript was a no-brainer. This is simply because it blends so well with HTML and CSS, and actually enhances your HTML/CSS skills as well. I've developed applications and games in various other programming languages including Java, Swift, C++, Dart. But the flexibility which JavaScript provides is unmatchable - even though it could be considered bad for beginners as it gives way more options than required to do a simple task.</p>
<p>Today, JavaScript is one of the most powerful languages on the planet because of its performance and omnipresence.</p>
<p>Personally, I feel like JavaScript has the potential to tap into so many popular industries like Machine Learning and Data Analysis, where Python still rules the game. It's even happening now with tools like Tensorflow.js! </p>
<p>However this was definitely not the case for JavaScript before. Earlier, it was a weak, non-performant language and was frowned upon. JavaScript was for "losers". </p>
<p>But not anymore. Let's see how JavaScript turned the tables in the last 10 years, why it has become stronger than ever, and why it is here to stay.</p>
<h1 id="heading-v8-the-beast-powering-javascript">V8: The beast powering JavaScript</h1>
<p>V8 is actually a JavaScript engine. What is a JavaScript engine, you might ask? A JavaScript engine is an interpreter which executes JavaScript code. A JavaScript engine can be implemented as a standard interpreter, or just-in-time (JIT) compiler that compiles JavaScript to bytecode in some form.</p>
<p>V8 is Google’s open source high-performance JavaScript and WebAssembly JIT engine, written in C++. It is used in Chrome and in Node.js, among others. V8 can run standalone, or can be embedded into any C++ application.</p>
<p>This is the piece of software which highly optimizes your JS code and converts it into machine code for the CPU to execute. Some of the tasks V8 handles are:</p>
<ol>
<li>Garbage Collection</li>
<li>Compilation to Machine code</li>
<li>Inline caching</li>
<li>Pointer compression</li>
<li>and much much more optimization</li>
</ol>
<p>As a matter of fact, pointer compression is a very new technique in V8 to boost memory optimization while having no effect on performance. If you're a geek, you can read more about how it is implemented on the official V8 blog.</p>
<p>The takeaway from this is that you can write JavaScript and sleep tight at night because your JS code is in very good hands.</p>
<h1 id="heading-mature-ecosystem-and-community">Mature ecosystem and community</h1>
<p>JavaScript has one of the most mature – if not THE most mature – ecosystems a programming language could ever have. The community for JavaScript is vast, and the entry barrier is extremely low. </p>
<p>You can fire up a browser (found on 100% of personal computers), open the console, and you'll find a JS engine waiting for you to run code! This was never the case with any other programming languages of such complexity. </p>
<p>As if the vast community wasn't enough, we have the <code>npm</code> and <code>yarn</code> package systems. You name it and there's a package for that on the <code>npm</code> registry – everything from creating random strings to handling streams and buffers in JavaScript. There's a very famous saying among JavaScript developers:</p>
<blockquote>
<p>What can be done in JavaScript, would eventually be done in JavaScript</p>
</blockquote>
<p>It's funny, but lowkey, I believe this. </p>
<p>If you enter as a beginner, there is very little chance you encounter a problem which nobody has encountered before. This is because all possible mistakes for simple JavaScript issues have probably already been asked about and archived on sites like Stack Overflow.</p>
<p>Frameworks and libraries like React, Angular, and Vue are paving the way for how future applications should be built. They're shifting the perspective towards declarative instead of imperative programming, the what instead of how. This lets developers develop quality applications without worrying about underlying high performant code.</p>
<h2 id="heading-omnipresence">Omnipresence</h2>
<p>JavaScript is present on:</p>
<ol>
<li>Front end (Browsers)</li>
<li>Back end (Node, Deno)</li>
<li>Android/iOS (React Native, NativeScript, etc.)</li>
<li>Desktop (Electron)</li>
<li>Hybrid (Ionic)</li>
</ol>
<p>What makes this possible? JS engines like V8 are written in C/C++ and can even be compiled on embedded systems! For other platforms, because browsers are always present (like on Andorid/iOS), they ship with a JS engine which can then be used to run any JS code, even for native apps in the case of React Native.</p>
<h2 id="heading-bleeding-edge-features-and-advancement">Bleeding edge features and advancement</h2>
<p>JavaScript standards are led by the ECMA-262 TC39 community, and wow are these people fast! ECMAScript releases a new standard of JavaScript every single year (see the new ECMAScript2020 features!). You as a developer can even request that new features be added to the language. </p>
<p>For instance, here are some pending bleeding edge features which might make it into JavaScript in the near future:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/Screenshot-2020-04-04-at-10.03.59-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can find all the proposals here: <a target="_blank" href="https://github.com/tc39/proposals">TC39 Proposals</a>.</p>
<h2 id="heading-javascript-is-fast-and-scalable">JavaScript is FAST and SCALABLE</h2>
<p>Of course, nothing really beats C/C++/Rust, but JavaScript is a fast - in the sense that V8 can generate highly optimized code by monitoring how your code executes, delaying the bits of execution which are not used, and optimizing the code segments which are used over and over. Especially when compared to its nearest competitors like Python. With the advancements in V8, it is becoming even more performant and memory efficient.</p>
<p>JavaScript (Node) is highly scalable (with supersets like TypeScript). Running on a single threaded architecture, people often criticize Node for its lack of threading environment, but the reality is it doesn't matter a lot. </p>
<p>The way you scale Node applications is not similar to how you'd scale a multi-threaded application. Node literally means "node" - a single node in a tree of processes. Node is scaled by running multiple instances of it and managing the cluster.</p>
<p>JavaScript leads the asynchronous event driven programming model of the industry, and does not need threads to scale. Instead, individual Node processes could be spawned to handle and utilize the complete CPU core. More on scaling Node later!</p>
<h2 id="heading-conclusion">Conclusion</h2>
<p>I love JavaScript, and using it I've created a developer platform for developers like you. There you can not only learn JavaScript, but also various other languages like C, C++, Java, Node, Python, and more! <a target="_blank" href="https://codedamn.com">Join here for free</a> and learn with other developers straight outta your browser!</p>
<p>JavaScript is here to stay, and rule the industry this decade. Do you agree? Tell me on my <a target="_blank" href="https://twitter.com/mehulmpt">twitter</a> and <a target="_blank" href="https://instagram.com/mehulmpt">Instagram</a> handles - let's connect!</p>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ 10 New JavaScript Features in ES2020 That You Should Know ]]>
                </title>
                <description>
                    <![CDATA[ By Mehul Mohan Good news – the new ES2020 features are now finalised! This means we now have a complete idea of the changes happening in ES2020, the new and improved specification of JavaScript. So let's see what those changes are. #1: BigInt BigInt,... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/javascript-new-features-es2020/</link>
                <guid isPermaLink="false">66d4605c246e57ac83a2c7ac</guid>
                
                    <category>
                        <![CDATA[ ecmascript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Fri, 03 Apr 2020 15:43:47 +0000</pubDate>
                <media:content url="https://www.freecodecamp.org/news/content/images/2020/04/es2020logo.jpg" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Mehul Mohan</p>
<p>Good news – the new ES2020 features are now finalised! This means we now have a complete idea of the changes happening in ES2020, the new and improved specification of JavaScript. So let's see what those changes are.</p>
<h1 id="heading-1-bigint">#1: BigInt</h1>
<p>BigInt, one of the most anticipated features in JavaScript, is finally here. It actually allows developers to have much greater integer representation in their JS code for data processing for data handling. </p>
<p>At the moment the maximum number you can store as an integer in JavaScript is <code>pow(2, 53) - 1</code> . But BigInt actually allows you to go even beyond that.  </p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/Screenshot-2020-04-03-at-8.21.47-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>However, you need to have an <code>n</code> appended at the very end of the number, as you can see above. This <code>n</code> denotes that this is a BigInt and should be treated differently by the JavaScript engine (by the v8 engine or whatever engine it is using). </p>
<p>This improvement is not backwards compatible because the traditional number system is IEEE754 (which just cannot support numbers of this size).</p>
<h1 id="heading-2-dynamic-import">#2: Dynamic import</h1>
<p>Dynamic imports in JavaScript give you the option to import JS files dynamically as modules in your application natively. This is just like how you do it with Webpack and Babel at the moment.</p>
<p>This feature will help you ship on-demand-request code, better known as code splitting, without the overhead of webpack or other module bundlers. You can also conditionally load code in an if-else block if you like. </p>
<p>The good thing is that you actually import a module, and so it never pollutes the global namespace.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/Screenshot-2020-04-03-at-8.26.27-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h1 id="heading-3-nullish-coalescing">#3: Nullish Coalescing</h1>
<p>Nullish coalescing adds the ability to truly check <code>nullish</code> values instead of <code>falsey</code> values. What is the difference between <code>nullish</code> and <code>falsey</code> values, you might ask?</p>
<p>In JavaScript, a lot of values are <code>falsey</code>, like empty strings, the number 0, <code>undefined</code>, <code>null</code>, <code>false</code>, <code>NaN</code>, and so on. </p>
<p>However, a lot of times you might want to check if a variable is nullish – that is if it is either <code>undefined</code> or <code>null</code>, like when it's okay for a variable to have an empty string, or even a false value.</p>
<p>In that case, you'll use the new nullish coalescing operator, <code>??</code></p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/Screenshot-2020-04-03-at-8.47.03-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<p>You can clearly see how the OR operator always returns a truthy value, whereas the nullish operator returns a non-nulllish value.</p>
<h1 id="heading-4-optional-chaining">#4: Optional Chaining</h1>
<p>Optional chaining syntax allows you to access deeply nested object properties without worrying if the property exists or not. If it exists, great! If not, <code>undefined</code> will be returned. </p>
<p>This not only works on object properties, but also on function calls and arrays. Super convenient! Here's an example:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/Screenshot-2020-04-03-at-8.51.58-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h1 id="heading-5-promiseallsettled">#5: Promise.allSettled</h1>
<p>The <code>Promise.allSettled</code> method accepts an array of Promises and only resolves when all of them are settled – either resolved or rejected. </p>
<p>This was not available natively before, even though some close implementations like <code>race</code> and <code>all</code> were available. This brings "Just run all promises – I don't care about the results" natively to JavaScript.</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/Screenshot-2020-04-03-at-8.54.58-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h1 id="heading-6-stringmatchall">#6: String#matchAll</h1>
<p><code>matchAll</code> is a new method added to the <code>String</code> prototype which is related to Regular Expressions. This returns an iterator which returns all matched groups one after another. Let's have a look at a quick example:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/Screenshot-2020-04-03-at-8.59.14-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h1 id="heading-7-globalthis">#7: globalThis</h1>
<p>If you wrote some cross-platform JS code which could run on Node, in the browser environment, and also inside web-workers, you'd have a hard time getting hold of the global object. </p>
<p>This is because it is <code>window</code> for browsers, <code>global</code> for Node, and <code>self</code> for web workers. If there are more runtimes, the global object will be different for them as well. </p>
<p>So you would have had to have your own implementation of detecting runtime and then using the correct global – that is, until now.</p>
<p>ES2020 brings us <code>globalThis</code> which always refers to the global object, no matter where you are executing your code:</p>
<p><img src="https://www.freecodecamp.org/news/content/images/2020/04/Screenshot-2020-04-03-at-9.02.27-PM.png" alt="Image" width="600" height="400" loading="lazy"></p>
<h1 id="heading-8-module-namespace-exports">#8: Module Namespace Exports</h1>
<p>In JavaScript modules, it was already possible to use the following syntax:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> utils <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils.mjs'</span>
</code></pre>
<p>However, no symmetric <code>export</code> syntax existed, until now:</p>
<pre><code class="lang-js"><span class="hljs-keyword">export</span> * <span class="hljs-keyword">as</span> utils <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils.mjs'</span>
</code></pre>
<p>This is equivalent to the following:</p>
<pre><code class="lang-js"><span class="hljs-keyword">import</span> * <span class="hljs-keyword">as</span> utils <span class="hljs-keyword">from</span> <span class="hljs-string">'./utils.mjs'</span>
<span class="hljs-keyword">export</span> { utils }
</code></pre>
<h1 id="heading-9-well-defined-for-in-order">#9: Well defined for-in order</h1>
<p>The ECMA specification did not specify in which order <code>for (x in y)</code>  should run. Even though browsers implemented a consistent order on their own before now, this has been officially standardized in ES2020.</p>
<h1 id="heading-10-importmeta">#10: import.meta</h1>
<p>The <code>import.meta</code> object was created by the ECMAScript implementation, with a <a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null"><code>null</code></a> prototype. </p>
<p>Consider a module, <code>module.js</code>:</p>
<pre><code class="lang-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">type</span>=<span class="hljs-string">"module"</span> <span class="hljs-attr">src</span>=<span class="hljs-string">"module.js"</span>&gt;</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>
</code></pre>
<p>You can access meta information about the module using the <code>import.meta</code> object:</p>
<pre><code class="lang-js"><span class="hljs-built_in">console</span>.log(<span class="hljs-keyword">import</span>.meta); <span class="hljs-comment">// { url: "file:///home/user/module.js" }</span>
</code></pre>
<p>It returns an object with a <code>url</code> property indicating the base URL of the module. This will either be the URL from which the script was obtained (for external scripts), or the document base URL of the containing document (for inline scripts).</p>
<h1 id="heading-conclusion">Conclusion</h1>
<p>I love the consistency and speed with which the JavaScript community has evolved and is evolving. It is amazing and truly wonderful to see how JavaScript came from a language which was booed on, 10 years go, to one of the strongest, most flexible and versatile language of all time today. </p>
<p>Do you wish to learn JavaScript and other programming languages in a completely new way? Head on to a <a target="_blank" href="https://codedamn.com">new platform for developers</a> I'm working on to try it out today! </p>
<p>What's your favorite feature of ES2020? Tell me about it by tweeting and connecting with me on <a target="_blank" href="https://twitter.com/mehulmpt">Twitter</a> and <a target="_blank" href="https://instagram.com/mehulmpt">Instagram</a>!</p>
<p>This is a blog post composed from my video which is on the same topic. It would mean the world to me if you could show it some love!</p>
<div class="embed-wrapper">
        <iframe width="560" height="315" src="https://www.youtube.com/embed/Fag_8QjBwtY" style="aspect-ratio: 16 / 9; width: 100%; height: auto;" title="YouTube video player" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen="" loading="lazy"></iframe></div>
 ]]>
                </content:encoded>
            </item>
        
            <item>
                <title>
                    <![CDATA[ Understanding How the Chrome V8 Engine Translates JavaScript into Machine Code ]]>
                </title>
                <description>
                    <![CDATA[ By Mayank Tripathi Before diving deep into the core of Chrome’s V8, first, let’s get our fundamentals down. All of our systems consist of microprocessors, the thing that is sitting inside your computer right now and allowing you to read this. Micropr... ]]>
                </description>
                <link>https://www.freecodecamp.org/news/understanding-the-core-of-nodejs-the-powerful-chrome-v8-engine-79e7eb8af964/</link>
                <guid isPermaLink="false">66c363fcb737bb2ce70731f8</guid>
                
                    <category>
                        <![CDATA[ Chromev8 ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ecmascript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ JavaScript ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Node.js ]]>
                    </category>
                
                    <category>
                        <![CDATA[ tech  ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ freeCodeCamp ]]>
                </dc:creator>
                <pubDate>Wed, 20 Dec 2017 05:12:25 +0000</pubDate>
                <media:content url="https://cdn-media-1.freecodecamp.org/images/1*T2RkznzWBPFp3JM3L7zx5A.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>By Mayank Tripathi</p>
<p>Before diving deep into the core of Chrome’s V8, first, let’s get our fundamentals down. All of our systems consist of microprocessors, the thing that is sitting inside your computer right now and allowing you to read this.</p>
<p>Microprocessors are tiny machines that work with electrical signals and ultimately do the job. We give microprocessors the instructions. The instructions are in the language that microprocessors can interpret. Different microprocessors speak different languages. Some of the most common are IA-32, x86–64, MIPS, and ARM. These languages directly interact with the hardware so the code written in them is called machine code. Code that we write on our computers is converted or compiled into machine code.</p>
<p>That’s what machine code looks like:</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*T2RkznzWBPFp3JM3L7zx5A.png" alt="Image" width="559" height="340" loading="lazy">
<em>Source : Google</em></p>
<p>It consists of instructions that are performed at a particular piece of memory in your system at a low level. You must feel lucky for not having to write all this to run your program!</p>
<p>High-level languages are abstracted from machine language. In the level of abstraction below, you can see how far JavaScript is abstracted from the machine level. C/C++ are relatively much closer to the hardware and hence much faster than other high-level languages.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*Hmr87--VeQ_GyZesKYtEeg.png" alt="Image" width="800" height="450" loading="lazy"></p>
<p>Now back to the V8 engine: V8 is a powerful open source Javascript engine provided by Google. So what actually is a Javascript Engine? It is a program that converts Javascript code into lower level or machine code that microprocessors can understand.</p>
<p>There are different JavaScript engines including <a target="_blank" href="https://en.wikipedia.org/wiki/Rhino_(JavaScript_engine)">Rhino</a>, <a target="_blank" href="https://en.wikipedia.org/wiki/WebKit#JavaScriptCore">JavaScriptCore</a>, and <a target="_blank" href="https://en.wikipedia.org/wiki/SpiderMonkey_(JavaScript_engine)">SpiderMonkey</a>. These engines follow the ECMAScript Standards. ECMAScript defines the standard for the scripting language. JavaScript is based on ECMAScript standards. These standards define how the language should work and what features it should have. You can learn more about ECMAScript <a target="_blank" href="https://www.ecma-international.org/publications/standards/Ecma-262.htm">here</a>.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*gZq22sBm1y3eq1NfhEaXeg.png" alt="Image" width="800" height="696" loading="lazy">
<em>Source: Google</em></p>
<p>The Chrome V8 engine :</p>
<ul>
<li>The V8 engine is written in C++ and used in Chrome and Nodejs.</li>
<li>It implements ECMAScript as specified in ECMA-262.</li>
<li>The V8 engine can run standalone we can embed it with our own C++ program.</li>
</ul>
<p>Let us understand the last point a little better. V8 can run standalone and at the same time we can add our own function implementation in C++ to add new features to JavaScript.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*PA3QZ_7EWgoDGNyJID_7MA.png" alt="Image" width="548" height="334" loading="lazy"></p>
<p>So for example: <code>print('hello world')</code>is not a valid statement in Node.js. It will give error if we compile it. But we can add our own implementation of the print function in C++ on top of the V8 which is open source at <a target="_blank" href="https://github.com/v8/v8">Github</a>, thus making the print function work natively. This allows the JavaScript to understand more than what the ECMAScript standard specifies the JavaScript should understand.</p>
<p>This is a powerful feature since C++ has more features as a programming language as compared to JavaScript, as it is much closer to hardware like dealing with files and folders on the hard drive.</p>
<p>Allowing us to write code in C++ and making it available to JavaScript makes it so we can add more features to JavaScript.</p>
<p>Node.js in itself is a C++ implementation of a V8 engine allowing server-side programming and networking applications.</p>
<p>Let’s now look at some of the open source code inside the engine. To do this, you need to go to the <a target="_blank" href="https://github.com/v8/v8/blob/master/samples/shell.cc">v8/samples/shell.cc</a> folder.</p>
<p>Here you can see the implementation of different functions such as <code>Print</code> and <code>Read,</code> which are natively not available in Node.js.</p>
<p>Below, you can see the implementation of the <code>Print</code> function. Whenever the <code>print()</code> function is invoked in Node.js, it will create a callback and the function will be executed.</p>
<p>Similarly, we can add our own implementation of different new functions in C++ inside V8 allowing it to be understood by Node.js.</p>
<p><img src="https://cdn-media-1.freecodecamp.org/images/1*GtV0dm8WOU4l43oK58SHqg.png" alt="Image" width="703" height="522" loading="lazy"></p>
<p>That is certainly too much to grab for a simple statement and that’s the amount of work V8 engine does under the hood.</p>
<p>Now you must have a clear understanding of how Node.js works and what actually is the Chrome V8 engine.</p>
<p>Thanks for reading this article. Let’s follow up on <a target="_blank" href="https://twitter.com/mayank_408"><strong>Twitter</strong></a>, <a target="_blank" href="https://www.linkedin.com/in/mayank-tripathi-a49563126/"><strong>Linkedin</strong></a>, <a target="_blank" href="https://github.com/mayank408"><strong>Github</strong></a><strong>,</strong> and <a target="_blank" href="https://www.facebook.com/profile.php?id=100001106266064"><strong>Facebook</strong></a>.</p>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
