menu

JavaScript Datatypes and Variables

JavaScript Datatypes and Variables - Important Points


36. Which of the following is a valid way to concatenate two strings in JavaScript?

A. str1 .concat(str2)

B. str1 + str2

C. str1 - str2

D. str1 * str2

Discuss Work Space

Answer: option b

Explanation:

The + operator can be used to concatenate two strings in JavaScript.

37. Which of the following is not a valid way to create a new array in JavaScript?

A. new Array(1, 2, 3)

B. [1, 2, 3]

C. Array(1, 2, 3)

D. {1, 2, 3}

Discuss Work Space

Answer: option d

Explanation:

The {} syntax is not a valid way to create a new array in JavaScript.

38. What is the result of the following code snippet: typeof undefined;

A. Undefined

B. null

C. undefined

D. None of the above

Discuss Work Space

Answer: option c

Explanation:

The typeof operator returns a string indicating the data type of an operand, and the data type of undefined is "undefined".

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

A. parseInt("42")

B. parseFloat("3.14")

C. Number("99")

D. All of the above

Discuss Work Space

Answer: option d

Explanation:

All three options are valid ways to convert a string to a number in JavaScript.

40. Which of the following is not a valid way to declare a constant in JavaScript?

A. const MY_CONST = "Hello";

B. const myConst = "World";

C. var myConst = "JavaScript";

D. let myConst = "Programming";

Discuss Work Space

Answer: option d

Explanation:

The let keyword is used to declare a variable that can be reassigned, but const is used to declare a constant that cannot be reassigned.


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