menu

JavaScript Basics

JavaScript Basics - Important Points


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

A. Number

B. Array

C. Object

D. Function

Discuss Work Space

Answer: option a

Explanation:

A primitive data type is a data type that is not an object and has no methods. Number is a primitive data type in JavaScript.

22.

What is the output of the following code?

console.log(3 + "2");

A. 5

B. 32

C. 6

D. 23

Discuss Work Space

Answer: option b

Explanation:

When a string and a number are concatenated in JavaScript, the number is converted to a string and concatenated with the other string.

23. Which of the following is not a looping structure in JavaScript?

A. for

B. while

C. do-while

D. repeat

Discuss Work Space

Answer: option d

Explanation:

There is no repeat loop in JavaScript.

24.

What is the output of the following code?

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

A. 2

B. 2.5

C. 3

D. 1

Discuss Work Space

Answer: option d

Explanation:

The % operator in JavaScript returns the remainder of dividing two numbers. In this case, 5 divided by 2 leaves a remainder of 1.

25.

What is the output of the following code?

console.log(2 + 2 + "2");

A. 42

B. 22

C. 221

D. 4

Discuss Work Space

Answer: option b

Explanation:

The expression is evaluated from left to right. First, 2 + 2 is evaluated to 4. Then, 4 is concatenated with the string "2" to produce "22".


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now