Question 1
What will be the output of the following code?
console.log(0.1 + 0.2 === 0.3);
1
undefined
2
true
3
false
4
TypeError
Question 2
What will be the output of the following code?
let x = {}; let y = x; console.log(x === y);
1
ReferenceError
2
undefined
3
true
4
false
Question 3
Which of the following is NOT a valid way to declare a JavaScript variable?
1
const x = 10;
2
var x = 10;
3
int x = 10;
4
let x = 10;
Question 4
What will be the output of the following code?
function test() { console.log(a); var a = 10; } test();
1
ReferenceError
2
TypeError
3
10
4
undefined
Question 5
What will be the output of the following code?
function test() { console.log(a); let a = 10; } test();
1
TypeError
2
10
3
undefined
4
ReferenceError
Question 6
What will be the output of the following code?
console.log(typeof null);
1
undefined
2
function
3
object
4
null
Question 7
What will be the output of the following code?
let a = [1, 2, 3]; let b = a; b.push(4); console.log(a);
1
[1, 2, 3]
2
ReferenceError
3
TypeError
4
[1, 2, 3, 4]
Question 8
What will be the output of the following code?
console.log(3 + "3");
1
33
2
3
3
NaN
4
TypeError
Question 9
What will be the output of the following code?
console.log([] == ![]);
1
false
2
true
3
ReferenceError
4
TypeError
Question 10
What will be the output of the following code?
(function() { var x = 5; })(); console.log(x);
1
ReferenceError
2
5
3
undefined
4
TypeError
Question 11
Which statement is true for let and var in JavaScript?
1
var is function-scoped, and let is block-scoped
2
Both are function-scoped
3
Both are block-scoped
4
let is function-scoped, and var is block-scoped
Question 12
What will be the output of this code?
const fun = function(){ if (true) { var x = 10; let y = 20; console.log(x); } console.log(x); } fun();
1
10
2
10 10
3
TypeError
4
ReferenceError
Question 13
What will be the output of this code?
const fun = function(){ if (true) { var x = 10; let y = 20; console.log(y); } console.log(y); } fun();
1
TypeError
2
20 20
3
ReferenceError
4
20 ReferenceError: y is not defined
Question 14
What will be the output of this code?
const fun = function(){ if (true) { var x = 10; let y = 20; console.log(x); } console.log(x); } fun(); console.log(x);
1
10 10 ReferenceError: x is not defined
2
ReferenceError: x is not defined
3
10 10 10
4
10 ReferenceError: x is not defined
Question 15
In JavaScript, which method is used to get the Unicode of a character?
1
asciiCodeAt()
2
getCode()
3
codeAt()
4
charCodeAt()
Question 16
What is the value of '1' + 1 in JavaScript?
1
11
2
NaN
3
2
4
TypeError