Junior — Senior
Investigation of variable lifting in an immediately invoked function
livecode
Task condition
Analyze how hoisting occurs for the variable name inside the IIFE, and predict what text will appear in the console.
var name = 'Коля!';
(function () {
if (typeof name === 'undefined') {
var name = 'Вася';
console.log('Пока, ' + name);
} else {
console.log('Привет, ' + name);
}
})();