menu

JavaScript Basics


1. What is the difference between null and undefined in JavaScript?

There is no difference between null and undefined.

null is a value that represents an empty object reference, while undefined is a value that represents an uninitialized variable.

undefined is a value that represents an empty object reference, while null is a value that represents an uninitialized variable.

null and undefined both represent an uninitialized variable.


2. What is the difference between a function declaration and a function expression in JavaScript?

There is no difference between a function declaration and a function expression.

A function declaration is hoisted to the top of the scope, while a function expression is not hoisted.

A function expression is hoisted to the top of the scope, while a function declaration is not hoisted.

A function declaration can only be used inside of an object, while a function expression can be used anywhere.


3. What does the keyword this refer to in JavaScript?

The global object

The parent object

The current object

The child object


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

string

number

boolean

object


5. 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


6.

What is the output of the following code?

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

2

2.5

3

1


7. What does NaN stand for in JavaScript?

Not a Name

Not a Number

Not a Null

Not a Boolean


8.

What is the output of the following code?

console.log(3 + "2");

5

32

6

23


9.

What is the output of the following code?

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

1

0

NaN

null


10.

What is the output of the following code?

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

5

6

23

6