Arrow Functinos in JavaScript

in #technology7 years ago

Arrow functinos are a new syntax for functions in JavaScript. Here are a few examples:

    let f = (a, b) => {
        let c = 4;
        return a + b - c;
    };

    let g = x => x * x;

Due to their brevity, arrow functions make writing functions easier and more readable. However, it sould be noted that arrow functions are not just a syntactical sugar, they have important differences with norrmal functions. The most important difference is that they don't have a this binding separate from the outer scope. This makes them very useful, for example, for using with array functions, such as forEach, etc. Also, they don't have an arguments binding. To remedy this, you can use the rest parameter syntax (...rest).

Sort:  

Upvote please

This wonderful post has received a bellyrub 6.17 % upvote from @bellyrub thanks to this cool cat: @ghasemkiani. My pops @zeartul is one of your top steemit witness, if you like my bellyrubs please go vote for him, if you love what he is doing vote for this comment as well.

nice content on your blog

This post has received a 10.17 % upvote from @booster thanks to: @ghasemkiani.

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 60420.16
ETH 2609.11
USDT 1.00
SBD 2.60