let sayBye = function () {
console.log(`Bye`);
}
let bye = sayBye;
sayBye = null; // X
bye(); // Y
Before asking this question, i searched in google and i found this post.
Then i thought, before line X the structure similar like this:
sayBye ---------------
|
| => function() {....}
|
bye-------------------
After the x line, I thought it was like this:
sayBye MEMORY
| => function() {....}
|
bye-------------------
But when i wrote bye in firefox developer tools i saw this
How is it possible? When i wrote let bye = sayBye;
is the sayBye coppied?
let sayBye = function () {
console.log(`Bye`);
}
let bye = sayBye;
sayBye = null; // X
bye(); // Y
console.log(bye);