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
View Answer Discuss Work SpaceAnswer: 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. !=
View Answer Discuss Work SpaceAnswer: 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
View Answer Discuss Work SpaceAnswer: 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
View Answer Discuss Work SpaceAnswer: 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
View Answer Discuss Work SpaceAnswer: option b
Explanation:
In JavaScript, null is considered to be an object data type.