menu

JavaScript Datatypes and Variables

JavaScript Datatypes and Variables - Important Points


1.

What is the data type of a variable that stores a whole number in JavaScript?

A. Number

B. String

C. Boolean

D. Object

Discuss Work Space

Answer: option a

Explanation:

The Number data type is used for storing numeric values in JavaScript.


2. Which of the following is not a valid data type in JavaScript?

A. Undefined

B. Null

C. NaN

D. Char

Discuss Work Space

Answer: option d

Explanation:

Char is not a valid data type in JavaScript. The other three are valid data types.

3. Which of the following is a valid way to declare a variable in JavaScript?

A. var myVar = 1;

B. let myVar = 1;

C. const myVar = 1;

D. All of the above

Discuss Work Space

Answer: option d

Explanation:

All three ways of declaring a variable are valid in JavaScript.

4. What is the value of a variable that has been declared but not initialized in JavaScript?

A. undefined

B. null

C. NaN

D. 0

Discuss Work Space

Answer: option a

Explanation:

If a variable has been declared but not initialized, its value is undefined.

5. Which of the following is a valid way to check the data type of a variable in JavaScript?

A. typeof myVar;

B. myVar.type();

C. myVar.getType();

D. typeOf(myVar);

Discuss Work Space

Answer: option a

Explanation:

The typeof operator can be used to check the data type of a variable in JavaScript.


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