menu

JavaScript Datatypes and Variables

JavaScript Datatypes and Variables - Important Points


31. Which of the following is not a valid way to declare a function in JavaScript?

A. function myFunc() {}

B. let myFunc = function() {};

C. const myFunc = () => {};

D. All of the above are valid

Discuss Work Space

Answer: option d

Explanation:

All three options are valid ways to declare a function in JavaScript.

32. Which of the following is a valid way to declare and initialize an object with multiple properties in JavaScript?

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

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

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

D. All of the above

Discuss Work Space

Answer: option a

Explanation:

All three options are valid ways to declare and initialize an object with multiple properties in JavaScript.

33. Which of the following is not a valid way to declare and initialize a string variable in JavaScript?

A. var myStr = "Hello";

B. let myStr = 'World';

C. const myStr = JavaScript;

D. myStr = "Programming";

Discuss Work Space

Answer: option d

Explanation:

To declare and initialize a string variable in JavaScript, you need to use the var, let, or const keyword.

34. What is the data type of a variable that stores an undefined value in JavaScript?

A. Undefined

B. Null

C. Object

D. None of the above

Discuss Work Space

Answer: option a

Explanation:

Undefined is considered to be a data type in JavaScript.

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

A. var myNum = 42;

B. let myNum = 3.14;

C. const myNum = -99;

D. All of the above

Discuss Work Space

Answer: option d

Explanation:

All three options are valid ways to declare and initialize a number 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