I recently saw this questions:
function compareMembers(person1, person2 = person) {
if (person1 !== person2) {
console.log('Not the same!');
} else {
console.log('They are the same!');
}
}
const person = { name: 'Lydia' };
compareMembers(person);
By seeing this, I am wondering how person can be the default value for person2.
const are not hoisted unlike var. And even if I try to do a console.log(person)
before function compareMembers I am getting Reference error.
IF any one can explain me how come the function has access to person as default value it would be really a great help.