I am working with JavaScript and I had some questions. What is the scope of a variable declared inside a block (if loop, for loop etc.)? I know that variable declared in a function is local to the function and once the execution of function is over than the variable is also goes out of scope. Is it true with the block statements in javascript? What happens when I declare a variable inside a block and use it outside the block. In C++ and Java when you do this than the behavior of variable is unknown. Thanks in advance for help.