menu

JavaScript Datatypes and Variables


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

str1 .concat(str2)

str1 + str2

str1 - str2

str1 * str2


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

var myVar = 1;

myVar = 1;

let myVar = 1;

const myVar = 1;


3. What is the data type of a variable that stores a boolean value in JavaScript?

Boolean

Number

String

Object


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

Undefined

Null

Object

None of the above


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

undefined

null

NaN

0


6. What is the data type of a variable that stores a boolean value in JavaScript?

Boolean

Bool

Bit

Flag


7. What is the data type of a variable that stores a string value in JavaScript?

String

Number

Boolean

Object


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

var 1myVar = 1;

let myVar1 = 1;

const MYVAR = 1;

let $myVar = 1;


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

parseInt("42")

parseFloat("3.14")

Number("99")

All of the above


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

let

const

var

int