menu

JavaScript Datatypes and Variables


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

Hello + "world";

Hello.concat("world");

Both A and B

None of the above


2. Which of the following is not a primitive data type in JavaScript?

Number

String

Object

Boolean


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

Null

Object

Undefined

None of the above


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

Object

Null

Undefined

Number


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

Function

Object

Method

Action


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

var myNum = 42;

let myNum = 3.14;

const myNum = -99;

All of the above


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

str1 .concat(str2)

str1 + str2

str1 - str2

str1 * str2


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

const MY_CONST = "Hello";

const myConst = "World";

var myConst = "JavaScript";

let myConst = "Programming";


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

var myBool = true;

let myBool = false;

const myBool = true;

All of the above


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

Boolean

Bool

Bit

Flag