menu

JavaScript Basics


1. What does the isNaN() function in JavaScript do?

Determines if a value is a number or not.

Determines if a value is a string or not.

Determines if a value is undefined or not.

Determines if a value is null or not.


2. What does the delete operator do in JavaScript?

Deletes a variable

Deletes a property of an object

Deletes an element from an array

Deletes a function


3.

What is the output of the following code?

var x = 5;
var y = 2;
console.log(x % y);

2

2.5

3

1


4.

What is the output of the following code?

console.log("2" * "3");

5

6

23

6


5. Which of the following is a valid way to create a function in JavaScript?

function myFunction() {}

var myFunction = function() {};

const myFunction = () => {};

all of the above


6. What is the purpose of the this keyword in JavaScript?

To refer to the global object.

To refer to the parent object.

To refer to the child object.

To refer to the current object.


7.

What is the output of the following code?

console.log(3 === "3");

1

0

NaN

null


8. Which of the following is not a way to loop through an array in JavaScript?

for loop

while loop

do-while loop

if statement


9. What is a callback function in JavaScript?

A function that is called when an error occurs.

A function that is called when a button is clicked.

A function that is passed as an argument to another function and is called when the first function has finished executing.

A function that is used to generate random numbers.


10. Which of the following is a primitive data type in JavaScript?

Number

Array

Object

Function