Variables and Data Types

Last Updated :
Discuss
Comments

Question 1

What happens when we console.log() a variable?

  • A

    It debugs the entire code

  • B

    It prints the value of the variable to the console

  • C

    It creates a memory block in system

  • D

    It is used to delete the variable's block of memory

Question 2

Which keyword is used to declare a variable that cannot be reassigned?

  • A

    var

  • B

    let

  • C

    const

  • D

    static

Question 3

Which of the following variable names are correct according to JavaScript?

  • A

    1name;

  • B

    #name;

  • C

    _name;

  • D

    @name;

Question 4

What will be the output of the following code?

JavaScript
let x = "Hello";
let y = 5;
console.log(x + y);


  • A

    Hello5

  • B

    5Hello

  • C

    NaN

  • D

    Hello

Question 5

What is the difference between var, let, and const?

  • A

    var is block-scoped, let and const are function-scoped.

  • B

    var is function-scoped, let and const are block-scoped.

  • C

    var and let are block-scoped, const is function-scoped.

  • D

    All are block-scoped.

Question 6

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

  • A

    Array

  • B

    Object

  • C

    Symbol

  • D

    Function

Question 7

What is the output of the following code?

JavaScript
let x; 
console.log(typeof x);


  • A

    null

  • B

    undefined

  • C

    object

  • D

    string

Question 8

Which of the following is a valid way to interpolate a variable into a string?

  • A

    "My age is " + age;

  • B

    `My age is ${age}`;

  • C

    "My age is ${age}";

  • D

    Both a and b

Question 9

How do you check the type of a variable in JavaScript?

  • A

    Using typeof

  • B

    Using instanceof

  • C

    Using Object.prototype.toString.call()

  • D

    All of the above

Question 10

What is the output of the following code?

JavaScript
console.log(5 + 5 + "5");


  • A

    "105"

  • B

    15

  • C

    NaN

  • D

    "55"

There are 10 questions to complete.

Take a part in the ongoing discussion