WorksheetsJS Assessment 70 MCQ
Total questions: 70
Worksheet time: 1hrs 20mins
Predict the output
console.log(10 + "20");
30
"30"
"1020"
Error
Output?
let x = 5;
console.log(x++);
4
5
6
Error
console.log(typeof []);
array
object
list
undefined
console.log(Boolean(""));
true
false
null
Error
What is the output of the following JavaScript code?
console.log(2 * "3");
"6"
6
NaN
Error
Output?
let a = [1,2];
a.push(3);
console.log(a.length);
2
3
Error
undefined
Output?
A
B
undefined
TypeError
console.log(1 < 2 < 3);
console.log(1 > 2 > 3);
console.log(3 > 2 > 1);
true false false
true true false
false true true
true false true
console.log(typeof NaN);
NaN
undefined
number
object
Output?
10
20
undefined
ReferenceError
console.log(!!"JS");
true
false
undefined
Error
console.log(0 == false);
true
false
undefined
Error
Output:
1 2 3
1 2 1
1 1 1
0 1 0
console.log(null == undefined);
console.log(typeof null === typeof undefined);
true
false
false
true
false
false
true
true
JavaScript is a ___ typed language.
Static
Dynamic
Strong
Compiled
Which keyword creates block scope?
var
let
const
both let & const
Output?
0 1 2
3 3 3
undefined
Error
Output?
undefined
42
Error
NaN
JavaScript runs primarily on?
OS
Browser
Compiler
Database
Output?
10
20
undefined
Error
console.log([] == []);
true
false
Error
undefined
var a = 10;
{
var a = 20;
}
console.log(a);
10
20
undefined
Error
function test() {
console.log(x);
var x = 5;
}
test();
5
undefined
Error
null
output?
3 3 3
0 1 2
undefined
Error
let arr = [1,2,3];
arr.length = 0;
console.log(arr);
[1,2,3]
[]
null
Error
console.log(3 && 0 || 5);
0
3
5
false
for(var i=0;i<3;i++){}
console.log(i);
2
3
Error
undefined
console.log(typeof typeof 10);
number
string
undefined
object
let a = {x:1};
let b = a;
b.x = 2;
console.log(a.x);
1
2
undefined
Error
console.log([1,2] == "1,2");
true
false
Error
undefined
console.log(!![]);
true
false
undefined
Error
Time complexity of array access by index?
O(n)
O(log n)
O(1)
O(n²)
function sum(a,b,c){
return a+b+c;
}
console.log(sum(1,2));
3
NaN
Error
undefined
console.log(Math.max());
0
undefined
-Infinity
Infinity
console.log(0.1 + 0.2 === 0.3);
true
false
Error
undefined
let x = [1,2];
let y = [...x];
y.push(3);
console.log(x.length);
2
3
Error
undefined
Output?
1 2 3
1 3 2
3 1 2
3 2 1
console.log(typeof null);
null
object
undefined
Error
Closure means?
Function inside function
Function with access to outer scope
Loop inside function
Object inside function
Hoisting applies to?
Variables
Functions
Both Variables & Functions
None
Output?
A B C D
A C D B
A D C B
A D B C
Event bubbling flows?
Parent → Child
Child → Parent
Random
None
Output?
1 2 3
2 1 3
2 3 1
321
Arrow functions bind this from?
Own scope
Parent scope
Global
Window
Output?
Error
Unhandled
Caught
undefined
(function(){
console.log(a);
let a = 10;
})();
10
Undefined
Reference Error
null
Output?
start timeout promise end
start promise timeout end
start end promise timeout
start end timeout promise
What is the output when this code is executed?
console.log({} + []);
0
"[object Object]"
NaN
Error
Given the following code:
let x = 10;
(function(){
console.log(x);
var x = 20;
})();
10
20
undefined
Error
What is the order of console output?
setTimeout(()=>console.log("A"),0);
Promise.resolve().then(()=>console.log("B"));
console.log("C");
A B C
C B A
B C A
C A B
Output:
console.log([1,2] + [3,4]);
[1,2,3,4]
"1,23,4"
"1,2,3,4"
Error
What is logged to the console?
function foo(){
return
{
a:1
}
}
console.log(foo());
{a:1}
undefined
Error
null
Output?
array
object
undefined
function
console.log(1 + "2" + "3" - 4);
119
123
19
Error
console.log([..."JS"]);
["JS"]
["J","S"]
"JS"
Error
Time Complexity?
O(n)
O(n log n)
O(n²)
O(2ⁿ)
Time complexity of binary search?
O(n)
O(log n)
O(n log n)
O(1)
Output?
5
undefined
TypeError
ReferenceError
let a = {x:1};
let b = {x:1};
console.log(a === b);
true
false
Error
undefined
console.log(parseInt("10px"));
10
NaN
Error
undefined
Output?
10 11
11 12
10 10
Error
Output?
10
undefined
Error
ReferenceError
In JavaScript, what does the event loop handle?
Heap
Stack
Async callbacks
Variables
In JavaScript, the call stack follows which ordering principle?
FIFO
LIFO
Random
Heap
Output?
A B C
C A B
C B A
A C B
Which causes memory leak?
Closures
Timers not cleared
Global variables
All
Prototype is used for?
Styling
Inheritance
Async
DOM
Which is mutable?
String
Number
Object
Boolean
Arrow functions do NOT have?
this
prototype
arguments
All
Output?
A B
B A
Error
undefined
