Posts

Showing posts from 2018

ES6 for Beginners - Part 1

Hello Readers, In this post I will walk you through the some of the basic ES6 Features. This post will help you if you are new to ES6 and help in learning other Front End Libraries. In this post I will walk you through the following ES6 Features Let and Const Arrow functions Default parameters for of loop Spread attributes Maps Sets Static methods Getters and Setters Let let is similar to var but let has scope. let is only accessible in the block level it is defined. if (true) { let a = 40; console.log(a); //40 } console.log(a); // undefined In the above example variable ‘a’ is defined inside If statement and so it’s not accessible outside the function. Another example: let a = 50; let b = 100; if (true) { let a = 60; var c = 10; console.log(a/c); // 6 console.log(b/c); // 10 } console.log(c); // 10 console.log(a); // 50 Const Const is used to assign a constant value to the variable. And the value cannot be changed. Its fixed. const a = 50