# JavaScript is evolving

DevFeed: [JavaScript is evolving](<https://devfeed.tech/articles/javascript-is-evolving-31991.md>)

Original publisher: [Read original article](<https://tech.finn.no2015/02/26/javascript-is-evolving/>)

Author: Tor Arne Kvaløy

Published: 2015-02-26T09:23:01Z

Content type: tutorial

Language: en

Sources: [Finn.no](<https://devfeed.tech/sources/finn-no.md>)

Topics: [ECMAScript](<https://devfeed.tech/topics/ecmascript.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [polyfill](<https://devfeed.tech/topics/polyfill.md>), [Babel](<https://devfeed.tech/topics/babel.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [browsers](<https://devfeed.tech/topics/browsers.md>)

Tags: [babel](<https://devfeed.tech/tags/babel.md>), [browser](<https://devfeed.tech/tags/browser.md>), [browsers](<https://devfeed.tech/tags/browsers.md>), [feature](<https://devfeed.tech/tags/feature.md>), [frontend](<https://devfeed.tech/tags/frontend.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [polyfill](<https://devfeed.tech/tags/polyfill.md>), [syntax](<https://devfeed.tech/tags/syntax.md>)

## AI overview

This tutorial explains how ECMAScript 6 improves JavaScript with methods such as includes and find, new syntax such as arrow functions and scoped variables, and class support. It also describes using polyfills for older browsers and Babel to transpile newer syntax to ECMAScript 5.

## Source excerpt

As a die-hard java-developer for several years I was quite annoyed by the fact that Java as a language lagged several years behind C#. (E.g. Java got lambdas last year, 6 years after C#, so standards are nice for compatibility, but tends to be slow to evolve.) Polyfill Now, as a frontend-developer and getting to know JavaScript, I have realized that JavaScript is lagging even further behind. Take for example the everyday case of checking if a string contains another string: "hello world".indexOf("hello") > -1 //=> true This is awkward and you know it, however JavaScript is evolving. The next version ECMAScript 6 is in its final phase, and will have, among several features, the following method: "hello world".includes("hello") //=> true Another new nice feature is for finding the first item in an array. It used to be written like this: for(int i = 0; i < array.length; i++){ if(array[i].something === something){ return array[i]; } } And now it can be written like: array.find(it => it.something === something); ECMAScript 6 is feature complete, and is started to be supported by modern browser like Chrome, Firefox and Internet Explorer 11. As for older browsers, great polyfills like core-js come to our rescue. Transpile While polyfills extend current objects with new methods, ECMAScript 6 also contains new language syntax. Let's look at the arrow function (also known as fat arrow): ["one", "two", "three"].map(v => v + "!") Older browser will not understand "=>" (for a long time!), so this code has to be transpiled to ECMAScript 5: ["one", "two", "three"].map(function (v) { return v + "!"; }); There are some great transcompilation tools out there, and the one we have used is Babel. You can even play around with it here. Scoped variables JavaScript will also get scoped variables (let and const): const hello = "Hello" if(true) { const hello = "Inner scoped hello" } This will transpile to: var hello = "Hello"; if (true) { var _hello = "Inner scoped hello"; } Classes And fina