DEV Community

Discussion on: JavaScript Question: Is this correct syntax?

Collapse
 
rconr007 profile image
rconr007 • Edited

In Javascript variables are hoisted (float to the top) as well as functions.
Meaning you can declare them anywhere but their values won't be assigned until you hit the line where you are assigning them. This also means that you can call the variables before they are declared with (var, let, const).
You won't get an error in this instance but he values of the variables are unassigned, but they have been declared which will have an undefined value.