Following is the code in which I need some clarification. I was expecting this code to console 'mango', 'apple', 'orange'
one by one similar to Option 2 but this is throwing another input which I am not getting how JavaScript is spitting this output.
const myFunc = (...data) => (data.map(console.log))
myFunc('mango', 'apple', 'orange')
Option 2 - (Expected Output)
var myFunc = (...data) => {
data.map(x => {
console.log(x)
})
}
myFunc('mango', 'apple', 'orange')
Correct my understanding with this please, as I was thinking that data.map(console.log)
will log the items only.