wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JS Assessment 70 MCQ

Total questions: 70

Worksheet time: 1hrs 20mins

Name
Class
Date
1.

Predict the output
console.log(10 + "20");

a)

30

b)

"30"

c)

"1020"

d)

Error

2.

Output?

let x = 5;

console.log(x++);

a)

4

b)

5

c)

6

d)

Error

3.

console.log(typeof []);

a)

array

b)

object

c)

list

d)

undefined

4.

console.log(Boolean(""));

a)

true

b)

false

c)

null

d)

Error

5.

What is the output of the following JavaScript code?

console.log(2 * "3");

a)

"6"

b)

6

c)

NaN

d)

Error

6.

Output?

let a = [1,2];

a.push(3);

console.log(a.length);

a)

2

b)

3

c)

Error

d)

undefined

7.

Output?

a)

A

b)

B

c)

undefined

d)

TypeError

8.

console.log(1 < 2 < 3);

console.log(1 > 2 > 3);

console.log(3 > 2 > 1);

a)

true false false

b)

true true false

c)

false true true

d)

true false true

9.

console.log(typeof NaN);

a)

NaN

b)

undefined

c)

number

d)

object

10.

Output?

a)

10

b)

20

c)

undefined

d)

ReferenceError

11.

console.log(!!"JS");

a)

true

b)

false

c)

undefined

d)

Error

12.

console.log(0 == false);

a)

true

b)

false

c)

undefined

d)

Error

13.

Output:

a)

1 2 3

b)

1 2 1

c)

1 1 1

d)

0 1 0

14.

console.log(null == undefined);

console.log(typeof null === typeof undefined);

a)

true

false

b)

false

true

c)

false

false

d)

true

true

15.

JavaScript is a ___ typed language.

a)

Static

b)

Dynamic

c)

Strong

d)

Compiled

16.

Which keyword creates block scope?

a)

var

b)

let

c)

const

d)

both let & const

17.

Output?

a)

0 1 2

b)

3 3 3

c)

undefined

d)

Error

18.

Output?

a)

undefined

b)

42

c)

Error

d)

NaN

19.

JavaScript runs primarily on?

a)

OS

b)

Browser

c)

Compiler

d)

Database

20.

Output?

a)

10

b)

20

c)

undefined

d)

Error

21.

console.log([] == []);

a)

true

b)

false

c)

Error

d)

undefined

22.

var a = 10;

{

var a = 20;

}

console.log(a);

a)

10

b)

20

c)

undefined

d)

Error

23.

function test() {

console.log(x);

var x = 5;

}

test();

a)

5

b)

undefined

c)

Error

d)

null

24.

output?

a)

3 3 3

b)

0 1 2

c)

undefined

d)

Error

25.

let arr = [1,2,3];

arr.length = 0;

console.log(arr);

a)

[1,2,3]

b)

[]

c)

null

d)

Error

26.

console.log(3 && 0 || 5);

a)

0

b)

3

c)

5

d)

false

27.

for(var i=0;i<3;i++){}

console.log(i);

a)

2

b)

3

c)

Error

d)

undefined

28.

console.log(typeof typeof 10);

a)

number

b)

string

c)

undefined

d)

object

29.

let a = {x:1};

let b = a;

b.x = 2;

console.log(a.x);

a)

1

b)

2

c)

undefined

d)

Error

30.

console.log([1,2] == "1,2");

a)

true

b)

false

c)

Error

d)

undefined

31.

console.log(!![]);

a)

true

b)

false

c)

undefined

d)

Error

32.

Time complexity of array access by index?

a)

O(n)

b)

O(log n)

c)

O(1)

d)

O(n²)

33.

function sum(a,b,c){

return a+b+c;

}

console.log(sum(1,2));

a)

3

b)

NaN

c)

Error

d)

undefined

34.

console.log(Math.max());

a)

0

b)

undefined

c)

-Infinity

d)

Infinity

35.

console.log(0.1 + 0.2 === 0.3);

a)

true

b)

false

c)

Error

d)

undefined

36.

let x = [1,2];

let y = [...x];

y.push(3);

console.log(x.length);

a)

2

b)

3

c)

Error

d)

undefined

37.

Output?

a)

1 2 3

b)

1 3 2

c)

3 1 2

d)

3 2 1

38.

console.log(typeof null);

a)

null

b)

object

c)

undefined

d)

Error

39.

Closure means?

a)

Function inside function

b)

Function with access to outer scope

c)

Loop inside function

d)

Object inside function

40.

Hoisting applies to?

a)

Variables

b)

Functions

c)

Both Variables & Functions

d)

None

41.

Output?

a)

A B C D

b)

A C D B

c)

A D C B

d)

A D B C

42.

Event bubbling flows?

a)

Parent → Child

b)

Child → Parent

c)

Random

d)

None

43.

Output?

a)

1 2 3

b)

2 1 3

c)

2 3 1

d)

321

44.

Arrow functions bind this from?

a)

Own scope

b)

Parent scope

c)

Global

d)

Window

45.

Output?

a)

Error

b)

Unhandled

c)

Caught

d)

undefined

46.

(function(){

  console.log(a);

  let a = 10;

})();

a)

 10

b)

Undefined

c)

Reference Error

d)

null

47.

Output?

a)

start timeout promise end

b)

start promise timeout end

c)

start end promise timeout

d)

start end timeout promise

48.

What is the output when this code is executed?

console.log({} + []);

a)

0

b)

"[object Object]"

c)

NaN

d)

Error

49.

Given the following code:

let x = 10;

(function(){

console.log(x);

var x = 20;

})();

a)

10

b)

20

c)

undefined

d)

Error

50.

What is the order of console output?

setTimeout(()=>console.log("A"),0);

Promise.resolve().then(()=>console.log("B"));

console.log("C");

a)

A B C

b)

C B A

c)

B C A

d)

C A B

51.

Output:

console.log([1,2] + [3,4]);

a)

[1,2,3,4]

b)

"1,23,4"

c)

"1,2,3,4"

d)

Error

52.

What is logged to the console?

function foo(){

return

{

a:1

}

}

console.log(foo());

a)

{a:1}

b)

undefined

c)

Error

d)

null

53.

Output?

a)

array

b)

object

c)

undefined

d)

function

54.

console.log(1 + "2" + "3" - 4);

a)

119

b)

123

c)

19

d)

Error

55.

console.log([..."JS"]);

a)

["JS"]

b)

["J","S"]

c)

"JS"

d)

Error

56.

Time Complexity?

a)

O(n)

b)

O(n log n)

c)

O(n²)

d)

O(2ⁿ)

57.

Time complexity of binary search?

a)

O(n)

b)

O(log n)

c)

O(n log n)

d)

O(1)

58.

Output?

a)

5

b)

undefined

c)

TypeError

d)

ReferenceError

59.

let a = {x:1};

let b = {x:1};

console.log(a === b);

a)

true

b)

false

c)

Error

d)

undefined

60.

console.log(parseInt("10px"));

a)

10

b)

NaN

c)

Error

d)

undefined

61.

Output?

a)

10 11

b)

11 12

c)

10 10

d)

Error

62.

Output?

a)

10

b)

undefined

c)

Error

d)

ReferenceError

63.

In JavaScript, what does the event loop handle?

a)

Heap

b)

Stack

c)

Async callbacks

d)

Variables

64.

In JavaScript, the call stack follows which ordering principle?

a)

FIFO

b)

LIFO

c)

Random

d)

Heap

65.

Output?

a)

A B C

b)

C A B

c)

C B A

d)

A C B

66.

Which causes memory leak?

a)

Closures

b)

Timers not cleared

c)

Global variables

d)

All

67.

Prototype is used for?

a)

Styling

b)

Inheritance

c)

Async

d)

DOM

68.

Which is mutable?

a)

String

b)

Number

c)

Object

d)

Boolean

69.

Arrow functions do NOT have?

a)

this

b)

prototype

c)

arguments

d)

All

70.

Output?

a)

A B

b)

B A

c)

Error

d)

undefined