Introduction
Namaste, In the post I will discuss 7 FAQs on Javascript fundamentals
Video Tutorial
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.
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.
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.
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.
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.
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.
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.