Skip to content

Tag: ECMAScript6

Arrow functions

I’m pretty impressed with Arrow functions in ECMAScript6. An Arrow function is very simple when compared to traditional function expressions. Arrow functions are always anonymous and do bind its own this, arguments, super and new.target properties. So, we can simply say Arrow functions are shorter functions and non-binding of this. Let’s begin with exploring shorter functions. To experiment shorter functions, we shall start creating a traditional function and then later we shall replace it with Arrow functions. var fruits = [‘mango’, ‘jack fruit’, ‘banana’]; var a = fruits.map(function (f) {… Read more Arrow functions

Template literals

Template literals in ES6 allows us to embed expressions to our string literals. We can use multi-line strings and string interpolation features with them. Template literals are enclosed by the back-tick (` `) instead of double or single quotes. var message = `single line string`; console.log(message); // single line string We can include place holders for string substitution using ${ } syntax var expression = “place holder”; // string substitution console.log(`this is a text with ${expression} in a line`); // this is a text with place holder in a line We… Read more Template literals