Jak używać niszczenia obiektów
// Noob [ not good ]
function getFullName(userObj) {
const firstName = userObj.firstName;
const lastName = userObj.lastName;
return `${firstName} ${lastName}`;
}
// master [ yap little bit ]
function getFullName(userObj) {
const { firstName, lastName } = userObj;
return `${firstName} ${lastName}`;
}
// hacker [ i prefer this way ]
function getFullName({ firstName, lastName }) {
return `${firstName} ${lastName}`;
}
// example func call
getFullName({
firstName: 'John',
lastName: 'Duo'
});
Easy Earthworm