how to pass the method of object to function normally?
as follows:
let JK = {
firstName: "John",
lastName: "Kennedy",
fullName: function() {
return this.firstName + this.lastName;
}
}
function getFullName({ fistName, lastName, fullName }) {
console.log(fullName());
}
getFullName(JK);
console result is NaN
of course, you can pass an object directly to function without deconstructing it. You can call the method fullName ().
what should I do correctly?