Fullstack Javascript Test
Language

The Language

Question #13

Your code has a function named doSomething. How do you invoke that function?

A) doSomething();

B) doSomething.call();

C) doSomething.apply();

D) All of the above

Question #14

Which of the following is not a keyword in JavaScript?

A) function

B) catch

C) array

D) this

Question #15

Which of the following values is not a Boolean false?

A) Boolean("")

B) Boolean("false")

C) Boolean(0)

D) Boolean(NaN)

Question #16

How do you get a random number in JavaScript?

A) randomNumber()

B) rand()

C) Number.random()

D) Math.random()

Question #17

Which statement is true about Objects and Functions in JavaScript?

A) Every object is a function

B) Every function is an object

C) A function always returns an object

D) Only pure functions are objects

Question #18

What will 0 && hi evaluate to when you run it with JavaScript?

A) false

B) 0

C) true

D) ReferenceError

Question #19

Which of the following expressions evaluates to true?

A) 3 == '3'

B) 3 === '3'

C) 3 != '3'

D) [3] == [3]

Question #20

Given that variable X holds this expression: 6 % 2

What will the expression X ? 'One': 'Two' return?

A) undefined

B) true

C) One

D) Two

Question #21

What is wrong with this line of code:

let result = if (3 == '3') { 42 } else { 0 };

A) You can’t use the let keyword in a top-level scope

B) JavaScript requires new lines after curly brackets and semicolons

C) In JavaScript, the if keyword starts a statement, not an expression

D) The == operator is not a valid one in JavaScript

Question #22

Which of the following methods is a special one in a JavaScript class definition?

A) new

B) render

C) create

D) constructor

Question #23

Your code is producing this error:

TypeError: Cannot read property 'reduce' of undefined.

What exactly does that mean?

A) You are calling a method named reduce on an object that’s declared but has no value

B) You are calling a method named reduce on an object that does not exist

C) You are calling a method named reduce on an object that’s has a null value

D) You are calling a method named reduce on an empty array

Question #24

Which variable-defining keyword behaves differently in function scopes than it does in block scopes?

A) let

B) var

C) const

D) They all behave exactly the same for both types of scopes

Question #25

What is a valid way to write an IIFE (Immediately Invoked Function Expression) in JavaScript?

A)

(function() {
  // code here
})();

B)

void function() {
  // code here
}();

C)

(function() {
  // code here
}());

D) All of the above

Question #26

In a browser (or in Node.js), how can you delay the execution of the function fn by at least 1 second?

A) delay(1000, fn);

B) setTimeout(fn, 1000);

C) sleep(1000); fn;

D) setDelay(fn, 1000);

Question #27

Which variable is an implicit parameter for every function in JavaScript?

A) argumentsList

B) argsArray

C) args

D) arguments

Question #28

What will this code do?

function sayHello() {
 console.log("hello");
};

var func = sayHello;
func.answer = 42;

console.log(sayHello.answer);

A) It will print: hello

B) It will print: 42

C) It will print: hello.42

D) It will throw an error

Question #29

What are the 2 values that this code will print?

function printA() {
  console.log(answer);
  var answer = 1;
};

printA();
printA();

A) undefined then undefined

B) 1 then undefined

C) 1 then 1

D) undefined then 1

Question #30

What will this code print?

var v = 1;

var f1 = function () {
  console.log(v);
}

var f2 = function() {
  var v = 2;
  f1();
};

f2();

A) 1

B) 2

C) undefined

D) This code will throw an error

Question #31

Which of the following statements about JavaScript scopes and closures are true?

A) Scopes have a lifetime

B) Closures span multiple scopes

C) Closures enable both read and write access

D) All of the Above

Question #32

Which of the following expression are TRUE in JavaScript?

A) typeof NaN === 'number'

B) typeof '' === 'string'

C) typeof undefined === 'undefined'

D) All of the above