Course
summary


    0 chapters available

Loading...

Make your website interactive with JavaScript

Difficulty: Beginner ● Progress: 0 / 0 modules completed

Variable scope

With the concept of function comes an additional, very important concept: the scope of variables, also called "scope" in English!

Let's take a simple example. When you create a variable right at the start of your script, this is what is called a "global" variable. This term is used to indicate that the scope of this variable is global to your entire code, and that it will therefore be accessible throughout your script, even inside a function.

Example:

let a = "Je suis une variable globale";

function test(){
    console.log(a);
}

test();

You need a free account to read this module