Question 1
Given the following code:
console.log(foo());
var foo = function() {
return "Function Expression";
};
function foo() {
return "Function Declaration";
}
What will be logged to the console?
Function Expression
Function Declaration
TypeError
ReferenceError
Question 2
What will be the output of the following JavaScript code?
let a = 1;
function outer() {
console.log(a);
let a = 2;
}
outer();
1
2
undefined
ReferenceError
Question 3
What will be the result of the following operation?
console.log(5 % 2);
1
2
1.5
5
Question 4
Which operator is used to compare both value and type?
==
===
!=
=
Question 5
Which of the following is a logical AND operator?
&&
||
!
^^
Question 6
Which of the following operators is used to assign a value to a variable?
==
===
=
:=
Question 7
Find the output of the following.
for (var i = 0; i < 3; i++) {
setTimeout(function() {
console.log(i); }, 100);
}
ReferenceError
3 3 3
0 1 2
undefined undefined undefined
Question 8
What is the output of this ternary operation?
const value = 10;
console.log(value > 5 ? "Yes" : "No");
Yes
No
Error
Undefined
Question 9
Which operator is used for optional chaining in JavaScript?
.?
?.
::
->
Question 10
What will the following code log?
console.log(5 == "5");
true
false
undefined
Error
There are 10 questions to complete.