name='pixxstudios'; console.log(name); // outputs pixxstudios var name;
In case of variable hoisting all the variable declarations are moved to the top of the code. If the variables are declared inside a function then they will move to the top of the function else if they are declared outside the function then they will move to the top of the script.
Remember that only variable DECLARATION are hoisted and INITIALIZATION are not hoisted. For example.
var i=10; var j=20; console.log(i+ " "+j); // outputs 10 20
but this code will give different output
var i=10; console.log(i+ " "+j); var j=20; // outputs 10 undefined
The above code is equivalent of
var i=10; var j; console.log(i+ " "+j); j=20; // outputs 10 undefined