Skip to content

Latest commit

 

History

History

global-local-scope

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

JavaScript - Global & Local scope

Global-scope - variables which are not defined in any if block or functions will have global scope.

let age = 20;
console.log("This is global scope age: ", age);

Local-scope - variables which are defined in any if block or functions will be local scope to that blocks.

if (age >= 15) {
    let age = 30;
    console.log("This is local scope age:", age);
}