Skip to content

Month: November 2016

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 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 = (f) {… Read more Arrow functions

Writing function in JavaScript

Let us create a function called cool and call it immediately and then we shall create the same function with small change in console message as follows. function cool(){ console.log(‘first function’); } cool(); function cool(){ console.log(‘second function’); } cool(); When we execute the above JavaScript code, we will get the output as second function second function In our code, the hoisting is happening. The JavaScript will move all the declaration to top. So when we create the second function it has overwritten the values. To avoid this we can declare… Read more Writing function in JavaScript