5 Things Every Developer Should Know about JavaScript ES6/ES2015

Hello there, I am Mehzad Galib, a junior web developer in the making. Today, I will discuss 5 things you should know before jumping into JavaScript ES6/ES2015, also known as ECMAScript 2015.

So, Let’s get started:

1. JavaScript Variable Declaration with ‘Let” and “Const” keyword:

In the earlier version of JavaScript, there was only one way to declare a variable, which was “var”, shorter form of the entire variable keyword. But JavaScript ES6 presents two new special keywords which is more powerful and descriptive.

i. The “let” keyword is used to declare something which may update later in the scope of function or loop or any conditional statement.

ii. The ‘const” keyword is used to declare some value which will not change in the scope. Both of these keywords are used in local scope, and known as local scope variable.

Example of “let” and “Const” variable

The “var” keyword is also used to declare a function, but it is global scoped, and hoisted by the program to the top.

2. Template Literals:

Templates are used to write some variable embedded as like string, and useful to declare some dynamic value within the template. It’s like the string method but better. Templates are written within the ``(back tick) signs found on the left of “1” key.

Example of Template Literals

3. Arrow Functions:

In the past, JavaScript function declaration is similar like other programming language functions, started with a “function” keyword, function name, parameter and something to return. But ES6 represents something more easy, the arrow function. Instead of using any of those, you can simply create a variable with a name, assign it with a value and use a “=>”(arrow) sign to return. This is very simple and elegant.

Example of an Arrow Function

4. Default Parameters:

In declaring regular funtions, we can assign some pre-made value for a parameter. If someone don’t pass the parameter when calling the function, the default parameter will be assigned, thus no error will occur.

Example of Default Parameters

5. Spread Operator:

We can use the elements of an array to another array, for doing that, no need to write down the elements of the array again. Instead, within the third bracet”[]” three dots”…” will be used, and then we can write the variable name in which the array is declared.

Example of spread Operator

Thanks for Reading this article. If you are new in web development and JavaScript, you can go through the video playlist I’ve added in the left.

Happy Learning!!!

I am a junior MERN Stack developer, basically front-end focused development is my passion. I can write scalable, re-usable code for development purpose.