var name = “John”

function exampleFunction() {

// Can use the variable ‘name’ here

}

// Can use the variable ‘name’ here

Notice how the variable can now be used anywhere, regardless of inside or outside of the function. This is because the variable was declared outside of any functions. It is a global variable, and therefore is said to have global scope. All scripts and functions can now access and make use of this variable.

Arrays

When programming, there are times when you will want to assign multiple values of the same type at once. If we used variables for this, it might look like this: