menu

JavaScript Datatypes and Variables

JavaScript Datatypes and Variables - Important Points


21. What is the data type of a variable that stores an object in JavaScript?

A. Object

B. Array

C. Dictionary

D. Set

Discuss Work Space

Answer: option a

Explanation:

The Object data type is used for storing objects in JavaScript.

22. Which of the following is a valid way to declare a variable with constant block scope in JavaScript?

A. var myConst;

B. let myConst;

C. const myConst;

D. Only A and B

Discuss Work Space

Answer: option c

Explanation:

The const keyword can be used to declare a variable with constant block scope in JavaScript.

23. Which of the following is not a valid way to declare and initialize an object in JavaScript?

A. var myObj = {};

B. let myObj = {key1: "value1", key2: "value2"};

C. const myObj = {key1: "value1", key2: "value2"};

D. myObj = {key1: "value1", key2: "value2"};

Discuss Work Space

Answer: option d

Explanation:

To declare and initialize an object in JavaScript, you need to use the var, let, or const keyword.

24. Which of the following is a valid way to access a property of an object in JavaScript?

A. myObj.key;

B. myObj["key"];

C. Both A and B

D. None of the above

Discuss Work Space

Answer: option c

Explanation:

Both dot notation and bracket notation can be used to access a property of an object in JavaScript.

25. Which of the following is not a valid JavaScript keyword?

A. let

B. const

C. var

D. int

Discuss Work Space

Answer: option d

Explanation:

int is not a valid JavaScript keyword.


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