Variable valin the next line
var val = 'ple'
rises to the top of the function.
The value of vals (inside the function) is equal undefined, which is false, therefore the condition ifis successful, since it !falseis equal to, trueand therefore, valinside the function is set to 'ple'. It looks something like
function func()
var val; // val = undefined
if(!val) { // it still undefined and !undefined is true
val = 'ple'; // so this code executes
}
console.log(val); // 'ple'
}
, javascript . val
val = 'ple';