tazzman tazzman - 1 month ago 7
Javascript Question

Javascript alias for "Function" keyword

Ahoi community,

Is there a possibility to define an alias for the javascript keyword "Function"?

var f = Function; // define Function alias

var foobar = f() // write 'f' as replacement for 'function'
{
console.log("foobar")
};

foobar();

Answer

Arrow functions is what I was looking for (thx Xufox).

It's useful to minify your JS (thx Beejor).

To me it is also better readable and faster to code :)

So the snippet in the original question would look like:

var foobar = () => console.log("foobar"); 

foobar();