Search code examples
javascriptscopedefaultvarlet

What is scope default of a variable defined by JavaScript var?


What is the scope of the default variable in javascript? I'm confused, I would like to know what Alcanse has the default variables I think is var or not?

For example:

x = 15 // ??
let y = 22 // let
var j = 33 // var

var? let?


Solution

  • Based on this source

    Scope of the variables declared without var keyword become global irrespective of where it is declared. Global variables can be accessed from anywhere in the web page. Visit Scope for more information.