menu

JavaScript Datatypes and Variables


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

let

const

var

int


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

Number

String

Object

Boolean


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

var myVar = 1;

let myVar = 1;

const myVar = 1;

All of the above


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

Object

Array

List

Set


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 not a valid way to declare and initialize an object in JavaScript?

var myObj = {};

let myObj = {key1: "value1", key2: "value2"};

const myObj = {key1: "value1", key2: "value2"};

myObj = {key1: "value1", key2: "value2"};


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 compare two values in JavaScript?

==

===

<=>

!=


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 way to declare and initialize a string variable in JavaScript?

var myStr = "Hello";

let myStr = 'World';

const myStr = JavaScript;

myStr = "Programming";