Successfully added
JavaScript
by Patrik
Function Scope
JavaScript has function scope: Each function creates a new scope.
Variables defined inside a function are not accessible (visible) from outside the function.
Variables declared with var
, let
and const
are quite similar when declared inside a function.
function varFunction() { | |
var message = "Hello"; // Function Scope | |
} | |
function letFunction() { | |
let message = "Hello"; // Function Scope | |
} | |
function constFunction() { | |
const message = "Hello"; // Function Scope | |
} |
Referenced in:
Comments