I was trying to wrap my head around the basics of JS
const someFun = (name) => {
return (name) => {
console.log(name + 'yolo')
return name
}
}
const myName = someFun('Varun')
console.log(myName)
This is returning (or logging)
(name) => {
console.log(name + 'yolo')
return name
}
Whereases I was expecting it to log name passed as parameter (varun).
Can someone explain me why? and also why do we need a function return statement to have a function?
And lastly, I also see (say, in case of my redux) a code which looks like this
export const updateData = (updatedData) => {
return function (dispatch) {
Here the main function takes updateData as a parameter but return function which takes dispatch as parameter (without any context in between). Can someone explain me this as well?