It's called hoisting. From the Mozilla docs (emphasis added):
Variable declarations, wherever they occur, are processed before any code is executed. The scope of a variable declared with var is its current execution context, which is either the enclosing function or, for variables declared outside any function, global.
The var message declared inside the if block hides the global message variable for all the code inside the function, including the call to console.log().
Two additional points. First, JavaScript separates variable declaration from variable initialization. That's why the local message variable has an undefined value when console.log(message) executes, rather than "wassup?!". Second, because hoisting is such counter-intuitive behavior (at least for programmers used to other languages), most JavaScript linting tools will warn you about var statements that are not at the start of their execution context. I strongly recommend that you find a linting tool (JSLint, JSHint, ESLint and JSCS come to mind) and use it.