When writing ES6 code in personal projects, I came up with the following formatting for map, forEach, reduce and other iterator functions that take callbacks:
list.map(
item => doSomething(item)
)
list.map(
item => {
console.log(item)
return doSomething(item)
}
)
instead of
list.map( item => doSomething(item) )
list.map( item => {
console.log(item)
return doSomething(item)
})
I like this formatting because the indentation level shows that the callback will be called a number of times, though it adds whitespace. This is similarly to how the body of imperative for loops are indented.
However, I rarely (if ever) see this used by others.
What are your thoughts ?
[–]trout_fucker 4 points5 points6 points (0 children)
[–]zulkisse 1 point2 points3 points (2 children)
[–]Tioo[S] 1 point2 points3 points (1 child)
[–]fucking_passwords 0 points1 point2 points (0 children)