DEV Community

Discussion on: The Arrow Function in JS!

Collapse
 
webreflection profile image
Andrea Giammarchi

I would write this, 'cause methods rarely ever benefit from arrows anyway:

const obj = {
    a: 5,
    foo() {
        console.log(this)
    }
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
shrihankp profile image
Shrihan

Agreed, I'd rather do it like that.

Collapse
 
ziratsu profile image
Ustariz Enzo

Agreed too, but I think that the function keyword is more comprehensible for a beginner, that's why I've used it there.
But in a real workflow the shorter version is better.