In the example above variable b is available since it's defined in the scope, but the value is undefined since it's set a line below. However variable c throws an error since it's not declared.

The same works for functions:

console.log(a());// 1functiona(){return1;}

Pay attention that this works only for function declarations. If you assign to a variable function expression, it behaves like a regular variable.

console.log(a);// undefined
console.log(a());// TypeError: a is not a functionvara=function(){return1;}

Scope:

The variable declared by var keywords and for function declarations will be available in the global scope by default, so they will be accessible in the entire application. In case module system is used (like CommonJS modules) the the declarations will be in the module scope. In case it's declared are inside a function they will be available only in the function scope.