menu

JavaScript Datatypes and Variables

JavaScript Datatypes and Variables - Important Points


26. What is the data type of a variable that stores a boolean value in JavaScript?

A. Boolean

B. Bool

C. Bit

D. Flag

Discuss Work Space

Answer: option a

Explanation:

The Boolean data type is used for storing boolean values (true or false) in JavaScript.

27. Which of the following is not a valid way to compare two values in JavaScript?

A. ==

B. ===

C. <=>

D. !=

Discuss Work Space

Answer: option c

Explanation:

<=> is not a valid comparison operator in JavaScript.

28. Which of the following is a valid way to declare and initialize a boolean variable in JavaScript?

A. var myBool = true;

B. let myBool = false;

C. const myBool = true;

D. All of the above

Discuss Work Space

Answer: option d

Explanation:

All three options are valid ways to declare and initialize a boolean variable in JavaScript.

29. Which of the following is a valid way to declare and initialize an array with multiple values in JavaScript?

A. var myArr = [1, 2, 3];

B. let myArr = {1, 2, 3};

C. const myArr = [1, 2, 3];

D. Only A and C

Discuss Work Space

Answer: option d

Explanation:

The [] syntax is used to declare an array in JavaScript, and you can initialize it with multiple values.

30. What is the data type of a variable that stores null in JavaScript?

A. Null

B. Object

C. Undefined

D. None of the above

Discuss Work Space

Answer: option b

Explanation:

In JavaScript, null is considered to be an object data type.


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