Are JavaScript variables declared in the body of an if statement scoped to the body?
1) Variables are visible for the whole function scope. Therefore, you should only declare them once. 2) You should not declare the variable twice in your example. I’d recommend declaring the variable at the top of the function, then just setting the value later: function actionPane(state) { var structure; if(state === “ed”) { structure = … Read more