Forward Thinking — a never-complete guide to modern JavaScript #2 Arrow Function

Tomasz Zwierzchoń
Oct 30, 2017 · 1 min read

I think everybody has seen many „=>” in JavaScript these days. The Arrow Function itself. In many cases it solves problems with „this”. It’s shorter. I really like it.

But we need to remember that Arrow Functions are a little different from traditional JavaScript functions — that’s what makes them special and useful for us.

Let’s examine differences which you can stumble upon:

  1. Cannot be used as constructors

This code will not work:

const Constructor = () => {
console.log("Mr. Watson, Come Here");
};
let myObject = new Constructor();

Try it by yourself.

It’s because Arrow Functions do not have Construct method.

2. No prototype

Because we cannot use new on them there is no use/need for prototype either.

3. No Arguments object inside

This code will not work:

const myFunc = () => {
console.log(arguments);
};
myFunc("myFirstArg", "my2ndArg");

Orba

We create and develop B2B & B2C e-commerce systems

Orba

We create and develop B2B & B2C e-commerce systems

Tomasz Zwierzchoń

Written by

IT Architect. FrontEnd Team Lead. #JavaScript on #IoT #UX #Vue.js Fan. I miss having free time, especially for dancing Tango.

Orba

We create and develop B2B & B2C e-commerce systems