DEV Community

Discussion on: Some of the best shortcuts when writing Javascript and Typescript

Collapse
 
nans profile image
Nans Dumortier • Edited

Thanks for the article!

Quick remark, in the lambda function section, I think you forgot the "function keyword" in the long example :

// Long way
arr.map((n) {
    return n*2;
})

should be

// Long way
arr.map(function (n) {
    return n*2;
})

also, regular functions and arrow functions do not exactly behave the same, so one should be careful about it 😄

Collapse
 
caelinsutch profile image
caelinsutch

Yes, sorry! I've been coding in Dart which has function declarations like that haha. True, lambda functions don't behave the exact same way but most of the time they're close enough! Thanks for the comment :)