Недавно мне задали этот вопрос на собеседовании в MERN, и я хочу прояснить свое понимание. Интервьюер представил этот код и спросил, что произойдет:
// Function declaration
console.log(fun); // What happens here?
fun(); // And here?
function fun() {
console.log("Normal function");
}
// Arrow function with var
console.log(funVar); // What about this?
funVar(); // And this call?
var funVar = () => {
console.log("Arrow function with var");
};
// Arrow function with const
console.log(funConst); // And this?
funConst(); // What happens here?
const funConst = () => {
console.log("Arrow function with const");
};
Подробнее здесь: https://stackoverflow.com/questions/798 ... ole-logfun
Мобильная версия