Basic javascript output based question

1 What will this code output?
console.log(typeof null); //object
2 What will this code output?
console.log(0.1 + 0.2 === 0.3); // false
3 What will this code output?
let a = [1, 2, 3];
let b = a;
b[0] = 4;
console.log(a);
// Expected Output: `[4, 2, 3]`
4 What will this code output?
function test() {
console.log(a);
var a = 1;
}
test();
// Expected Output: undefined
5 What will this code output?
console.log([1] == true);
// Expected Output: true
6 What will this code output?
console.log(typeof NaN);
// Expected Output: number
7 What will this code output?
console.log([2] == [2]);
// Expected Output: false
8 What will this code output?
console.log(1 + "2" + "2");
// Expected Output: "122"
9 What will this code output?
let x = 10;
(function() {
console.log(x);
let x = 20;
})();
// Expected Output: ReferenceError
10 What will this code output?
var obj = { a: 1 };
var obj2 = obj;
obj2.a = 2;
console.log(obj.a);
// Expected Output: 2
11 What will this code output?
const obj = {
a: 1,
b: 2,
get sum() {
return this.a + this.b;
}
};
console.log(obj.sum);
// Expected Output: 3
12 What will this code output?
const arr = [1, 2, 3];
arr[10] = 11;
console.log(arr.length);
// Expected Output: 11
13 What will this code output?
console.log(!!"");
// Expected Output: false
14 What will this code output?
console.log(null == undefined);
// Expected Output: true
15 What will this code output?
const fn = () => {
return
{
name: "John"
};
}
console.log(fn());
// Expected Output: undefined
Share: