Test your JavaScript Skills: Fundamentals-2

Photo by RetroSupply on Unsplash

Test your JavaScript Skills: Fundamentals-2

Part 2

Introduction

Namaste, In the post I will discuss 7 FAQs on Javascript fundamentals

Video Tutorial

  1. Identify the output of the below program

     let mydata = NaN/2;
     console.log("mydata", mydata);
    

    a. Error

    b. NaN

    c. Undefined

    d. 100.5

    e. null

    Answer: b

    Reason: NaN when divided is still Not a Number.

  2. Identify the output of the below program

     let mydata = 1/0;
     console.log("mydata", mydata);
    

    a. 1

    b. Error

    c. 0

    d. Infinity

    e. NaN

    Answer: d

    Reason: In Javascript a non-zero number divided by 0 is infinity.

  3. Identify the output of the below program

     let mydata = 0/0;
     console.log("mydata", mydata);
    

    a. 3

    b. 0

    c. Error

    d. null

    e. NaN

    Answer: e

    Reason: Zero divided by 0 is NaN.

  4. Identify the output of the below program

     let mydata = undefined;
     console.log("type", typeof mydata);
    

    a. error

    b. null

    c. object

    d. undefined

    e.number

    Answer: d

    Reason: A variable containing undefined as a value is an undefined type.

    Undefined is 1 of the 7 primitives.

  5. Identify the output of the below program

     let mydata = NaN * 2;
     console.log("mydata", mydata);
    

    a. null

    b. undefined

    c. NaN

    d. Error

    e.false

    Answer: c

    Reason: NaN when multiplied by a number is still Not a Number.

  6. Identify the output of the below program

     let mydata = 0/3;
     console.log("mydata", mydata);
    

    a. 0

    b. 3

    c. Error

    d. NaN

    e.undefined

    Answer: a

    Reason: Zero divided by any number (except for 0) is 0.

  7. Identify the output of the below program

     let mydata = NaN + 2;
     console.log("type", typeof mydata);
    

    a. boolean

    b. number

    c. NaN

    d. Error

    e.string

    Answer: b

    Reason: NaN is a number type.

Video Tutorial

Did you find this article valuable?

Support Programming with Mahavir by becoming a sponsor. Any amount is appreciated!