var clientData = {
id: 1969,
fullName: "Not Set",
setUserName: function (firstName, lastName) {
clientData.fullName = firstName + " " + lastName;
console.log(clientData.fullName);
}
};
function getUserInput(firstName, lastName, callback) {
//why can't I say clientData.callback (firstName, lastName); instead
callback (firstName, lastName);
}
getUserInput ("Peter", "Pan", clientData.setUserName);
As is commented in the code, why can't I say clientData.callback (firstName, lastName); if what the callback argument is referencing is the function that should be accessible from clientData with dot access? If clientData.setUserName is just a reference to a function object, I shouldn't be accidentally saying clientData.clientData.setUsername with my commented code, right?
I'm a beginner, and because it's not working I'm sure I'm thinking of something wrong.
clientData.setUserName(), you cannot sayclientData.callback()- there is no such method.