Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following JavaScript code?
const pi=3.14;
var pi=4;
console.log(pi);

What will be the output of the following JavaScript code?
const pi=3.14;
var pi=4;
console.log(pi);
a) This will flash an error
b) Prints 4
c) Prints 3.14
d) Ambiguity

Answer: a
Explanation: Const keyword fixes the value of the variable. Const keyword can not be redefined. Therefore attempts to alter the value or re-declaration causes errors.

Join The Discussion