const parkReport = () => {
return {
averageAge: () => {
return console.log('Something');
}
}
};
const initialize = ( parkReport => {
return parkReport.averageAge();
})(parkReport);
在IIFE initialize
parkReport.averageAge()
中显示的错误不是函数。如何从AverageAge()
调用嵌套initialize
?
答案 0 :(得分:0)
您需要调用parkReport
函数。在这里,您将parkReport
作为callback
传递给IIFE
。所以你需要call
它才能期待从它返回的内容。
const parkReport = () => {
return {
averageAge: () => {
return console.log('Something');
}
}
};
const initialize = (parkReport => {
return parkReport() // call it
.averageAge(); // and get the age
})(parkReport);