What is the output of the following code snippet? | JavaScript Output Based Question | JS Variables
@Yomesh Gupta
function compute() {
const condition = true;
if (condition) {
let a = false;
let b = false;
}
return {
a: a || null,
b: b || null
}
}
var r = compute();
// What do you think would be the output?
console.log(r);
Option 1
{ "a": false, "b": false }
Option 2
{ "a": null, "b": null }
Option 3
{ "a": undefined, "b": undefined }
Option 4
There will be an error.