Global Scope

Global Scope

  • Variables defined outside of a function are in in the Global Scope

Example

// Global function because it was declared outside of a function
const name = 'Simone Biles'

console.log(name)

function bestGymnastEver() {
  // 'name' variable is accessible here and everywhere else because it is global
  console.log(name)
}

logName() // logs 'Simone Biles'

JS Bin on jsbin.com