menu

JavaScript Datatypes and Variables


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

==

===

<=>

!=


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


3.

What is the data type of a variable that stores a whole number in JavaScript?

Number

String

Boolean

Object


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

Object

Null

Undefined

Number


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

function myFunc() {}

let myFunc = function() {};

const myFunc = () => {};

All of the above are valid


6. Which of the following is a valid way to check the data type of a variable in JavaScript?

typeof myVar;

myVar.type();

myVar.getType();

typeOf(myVar);


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

Number

String

Object

Boolean


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

var myVar;

let myVar;

const myVar;

All of the above


9. Which of the following is a valid way to declare and initialize an array with multiple values in JavaScript?

var myArr = [1, 2, 3];

let myArr = {1, 2, 3};

const myArr = [1, 2, 3];

Only A and C


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

new Array(1, 2, 3)

[1, 2, 3]

Array(1, 2, 3)

{1, 2, 3}