I am trying to understand the function call in this scenario, How does state get resolved to viewFunc in addView function definition ( hooks between these ) and takes defaultData as function argument ?
var defaultData = {
property: [
{
name: 'Adam',
type: 'javascript'
},
{
name: 'Tom',
type: 'Typescript'
}
]
};
function addView(viewFunc){
console.log(" 1. Step I");
viewFunc(defaultData);
console.log(" 2. Step III ");
}
addView((state)=>{
console.log(" 3. Step II & lenght of data set : "+state.property.length);
})
Output:
1. Step I
3. Step II & lenght of data set : 2
2. Step III
defaultDatato the callback:viewFunc(defaultData);. That's how it gets its value. It's the same as with any other function call.