menu

JavaScript Datatypes and Variables


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

Number

String

Object

Boolean


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

var myConst;

let myConst;

const myConst;

Only A and B


3. Which of the following is not a valid data type in JavaScript?

Undefined

Null

NaN

Char


4. 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


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

Undefined

null

undefined

None of the above


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

Object

Array

Dictionary

Set


7. Which of the following is not a valid way to compare two values in JavaScript?

==

===

<=>

!=


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

Object

Null

Undefined

Number


9. 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


10. Which of the following is a valid way to declare an empty array in JavaScript?

var myArr = [];

let myArr = {};

const myArr = ();

All of the above