有人可以向我澄清这段代码(仅关于回调函数和参数)吗?
提前感谢您的帮助。
var allUserData = [];
function logStuff(userData) {
if (typeof userData === 'string') {
console.log(userData);
} else if (typeof userData === "object") {
for (var item in userData) {
console.log(item + ": " + userData[item]);
}
}
}
function getInput(options, callback) {
allUserData.push(options);
callback(options); //What is that?
}
getInput({ name: 'Rich', speciality: 'JavaScript' }, logStuff); //How that's work?