Coding Basics JavaScript programming WEB DEVELOPMENT

3 Important Thing About JavaScript Every Developer Should know



ECMAScript is an updated version of javascript. It was released in 2015 that’s why we also know ES6 as ECMAScript 2015. This is fully compatible with all modern browsers from 2017. In this blog, you learn about different keywords used in javascript or ES6. After reading this blog you get clear information about arrow function, let, var, and const keyword used in modern javascript.

Let’s see some major improvements done in ECMAScript 6

1 Var and let keyword

Var keyword is used to declare a variable in javascript. It is good practice to declare variables in javascript. It helps us to read and execute code fast and easily.

You can assign numbers, floats, string to variables using the var keywords in javascript. When you declare a variable using the var keyword it can be accessed from out of the scope. 

If you don’t want to access code from outside of scope. You can use the let keyword which will help you to make variables accessible only in blocks not from the outside of the scopes.

Javascript is case-sensitive programming which is also valid in this ECMAScript 6 upgrade. You can not make variables using numbers and any other special characters like a hashtag ( # ), dollar sign( $ ), etc. 

So, how you can declare a variable is ES 6. There is not the best way to choose any name you want but make sure it is related to the work you want to do with that variable. If the variable is log you can use the camel case to make a variable name readable and easily understandable to readers of your code.

Camelcase refers to camel where your first variable name is a small letter but when the second word starts here is the latter in the capital. You will more understand in the example so let’s see an example to understand var and let keywords in ECMAScript 6


var i = 5;

let i = 4;


The answer was 5

Is because var i is accessible and let i is not accessible from scope.

2 Const keyword

This is a very special variable and only used when you need it. Because when you define a variable using const keyword. Then you can not use it to declare another variable. The const is called constant as its name clears the idea of the variable. You make using the const keyword is constant and not changed after it’s declared. You can use it when you need to define some variable for the whole code block and do not want to change by accident. 

It is very helpful when you make lots of functions and do not want to override any variable. 


const x = 5;
var x = 7;


You will see the error like read-only or x is already been declared 

Try this code in the console panel press right-click in the browser select inspect element and go to console panel and paste this code and you will see the error. Because we can not assign a variable if we declared it as constant with the const keyword

3 Arrow Function

This amazing feature introduced in ECMAScript 6 here can remove noise from simple functions and make our code more beautiful by using the arrow function ( => ). This is very simple to use. Let’s see this by the following example.

Regular function:

function(i) {
 return a + 100;

To make this an arrow function first we remove the name function. And assign it to an as constant using the const keyword we learned above. Declaring as const when making arrow function is a good idea because function expressions are always in constant value. 

const a => { return  a + 100; }

Now we can also remove the curly braces and return the keyword. But using a return keyword is a good habit to keep it all depends on you. So here is the final code to replace the regular function using the arrow function.

const a => a + 100;

So, there are three important things you have to know about the modern javascript of ES6. if you want to learn more about javascript join the following courses.

Best Javascript courses for you

The Complete JavaScript Course 2021: From Zero to Expert!
JavaScript Basics for Beginners

Also, Read

13 Important Things To Know About Laptops

How to get an amazing laptop which satisfies your need

5 Wonderful & Easy Hacks To Buy Your First Laptop

Share This Post To Your Friends

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *