Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

JS Quiz

Total questions: 14

Worksheet time: 11mins

Name
Class
Date
1.

Which of the following is wrong?

a)

var greeting = `\`Yo\` World!`;


//output - `Yo` World!

b)

var user = {name: 'World'};

console.log(`Thanks for getting this into V8, ${user.name.toUpperCase()}.`);


//output - Thanks for getting this into V8, WORLD.

c)

console.log("string text line 1 \ string text line 2");


//output - string text line 1
string text line 2

2.

I want to extract 'hello' and 'array' from the array using destructuring

a)

 var [greeting,name] = ["Hello", "I" , "am", "Array"]; 

b)

 var [greeting,,,name] = ["Hello", "I" , "am", "Array"];

c)

 var array = ["Hello", "I" , "am", "Array"]; 

greeting = array[0];

name = array[2];

3.

Select all the correct options.

a)

var[greeting = "hi", name = “Array"] = ["hello"];

b)

let person = {name: "Object", country: "India", job: "Developer"};

let {name = "Name", company = "Epsilon"} = person;

c)

const message = `Some weird characters: \${abc}`;

d)

var a = 10;

var b = 5;

var result = `The sum of ${a} and ${b} is ${a + b} difference is ${a-b}`;

4.

A function with a provided this and further arguments are provided as a comma separated list

a)

Apply

b)

Call

c)

Bind

d)

On

5.

Returns a new function whose this value is bound to the provided value.

a)

Call

b)

Apply

c)

Bind

d)

Bound

6.

Calls a function with a provided this value. Further arguments are provided as a single array

(a)  

7.

Bind executes the function it was called upon right away

a)

True

b)

False

8.

[a, b, ...rest] = [10, 20, 30, 40, 50];

console.log(rest);

a)

50

b)

[30, 40, 50]

c)

[10, 20]

9.

let a, b;

[a=5, b=7] = [1];

console.log(a);

console.log(b)

a)

1 7

b)

5 7

c)

1 1

d)

5 1

10.

let a = 1;

let b = 3;

[a, b] = [b, a];

console.log(a);

a)

1

b)

3

11.

const arr = [1,2,3];

[arr[2], arr[1]] = [arr[1], arr[2]];

console.log(arr);

a)

[3,1,2]

b)

[1,3,2]

c)

[1,2,3]

12.

const o = {p: 42, q: true};

const {p: foo, q: bar} = o;

console.log(foo);

a)

undefined

b)

42

c)

p

13.

var func = function() {

console.log(this)

}.bind(1);


func();

a)

Number {1}

b)

1

c)

window

14.

function checkFun(a, b, c){

console.log(this);

console.log(a);

console.log(b);

console.log(c);

}

checkFun.apply(1,[2,3,4]);

a)

1

2

3

4

b)

[Number: 1]

2

3

4

c)

this

2

3

4