var y = 1;
if (function f(){}) {
y += typeof f;
}
console.log(y);
In the above example, the output is 1undefined as the if statement code executes at runtime, and the statement inside the if condition is evaluated during run time.
var k = 1;
if (1) {
eval(function foo(){});
k += typeof foo;
}
console.log(k);
output : 1undefined
The if condition evaluates this statement using eval and the eval(function foo(){}) returns true. But as the statement executes at runtime the output will be 1undefined.
var k = 1;
if (1) {
function foo(){};
k += typeof foo;
}
console.log(k);
Here, the typeof returns function and the output is :
1function
if (function f(){}) {
y += typeof f;
}
console.log(y);
In the above example, the output is 1undefined as the if statement code executes at runtime, and the statement inside the if condition is evaluated during run time.
var k = 1;
if (1) {
eval(function foo(){});
k += typeof foo;
}
console.log(k);
output : 1undefined
The if condition evaluates this statement using eval and the eval(function foo(){}) returns true. But as the statement executes at runtime the output will be 1undefined.
var k = 1;
if (1) {
function foo(){};
k += typeof foo;
}
console.log(k);
Here, the typeof returns function and the output is :
1function
No comments:
Post a Comment