JS Daily 18 - Variable Declaration Using Const

Last updated on 8 Dec, 2020

What is the output of following code?

const a;
a = 10;
a = 20;

Above code throws error in line 1. The error says SyntaxError: Missing initializer in const declaration.

A const variable should be initialized at the time of declaration itself like const a = 10.

--- ○ ---
Joby Joseph
Web Architect