[javascript] What is the purpose of the var keyword and when should I use it (or omit it)?

Besides scopes issue, some folks also mention hoisting, but no one gave an example. Here's one for global scope:

_x000D_
_x000D_
console.log(noErrorCase);_x000D_
var noErrorCase = "you will reach that point";
_x000D_
_x000D_
_x000D_

_x000D_
_x000D_
console.log(runTimeError);_x000D_
runTimeError = "you won't reach that point";
_x000D_
_x000D_
_x000D_