map function args vs no args

Viewed 34

I'm not sure why but the following two lines aren't the same, anyone know why?

const newArray = clone.current.map(item => mapNewProperty(item, 'yellow'));

const newArray = clone.current.map(mapNewProperty(item, 'yellow'));

The second works as intended, the first doesn't at all.

Here's the function:

const mapNewProperty = (item, color) => {
    return {...item, backgroundColor: color}
}
0 Answers
Related