Java Reference
In-Depth Information
"d inside function: 6"
"d is not defined"
In this example,
d
is also only defined inside the function, but by using
var
it has local
scope and is only accessible inside the function. When we try to log the value of
d
outside
the function, it causes an error because d is not defined outside its scope.