menu

JavaScript Datatypes and Variables

JavaScript Datatypes and Variables - Important Points


11. Which of the following is a valid way to declare a variable with global scope in JavaScript?

A. var myVar;

B. let myVar;

C. const myVar;

D. All of the above

Discuss Work Space

Answer: option a

Explanation:

Using the var keyword to declare a variable without specifying a block scope makes it a global variable.

12. Which of the following is a valid way to convert a string to a number in JavaScript?

A. parseInt("10");

B. 10.toInt();

C. 10.toNumber();

D. Number("10");

Discuss Work Space

Answer: option a

Explanation:

The parseInt() function can be used to convert a string to a number in JavaScript.

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

A. Object

B. Null

C. Undefined

D. Number

Discuss Work Space

Answer: option a

Explanation:

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

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

A. var 1myVar = 1;

B. let myVar1 = 1;

C. const MYVAR = 1;

D. let $myVar = 1;

Discuss Work Space

Answer: option a

Explanation:

Variable names in JavaScript cannot start with a number.

15. What is the data type of a variable that stores a function in JavaScript?

A. Function

B. Object

C. Method

D. Action

Discuss Work Space

Answer: option b

Explanation:

In JavaScript, functions are considered to be objects.


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