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

Tomasz Zwierzchoń
Orba
Published in
1 min readOct 30, 2017

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");

--

--

Tomasz Zwierzchoń
Orba
Editor for

Skilled team leader and trainer. I excel at translating between business and technical languages. I am well-versed in agile methodologies, BDD, and TDD.