title: javascript variable scope in the IF statement
body: <p>Are variables declared and assigned in an "if" statement visible only within that "if" block or within the whole function? </p>
  
  <p>Am I doing this right in the following code? (seems to work, but declaring "var structure" multiple times seems awkward) any cleaner solutions?</p>
  
  <pre><code>    function actionPane(state) {
      if(state === "ed") {
          var structure = {
              "element" : "div",
              "attr" : {
                  "class" : "actionPane"
              },
              "contains" : [{
                  "element" : "a",
                  "attr" : {
                      "title" : "edit",
                      "href" : "#",
                      "class" : "edit"
                  },
                  "contains" : ""
              }, {
                  "element" : "a",
                  "attr" : {
                      "title" : "delete",
                      "href" : "#",
                      "class" : "delete"
                  },
                  "contains" : ""
              }]
          }
      } else {
          var structure = {
              "element" : "div",
              "attr" : {
                  "class" : "actionPane"
              },
              "contains" : [{
                  "element" : "a",
                  "attr" : {
                      "title" : "save",
                      "href" : "#",
                      "class" : "save"
                  },
                  "contains" : ""
              }, {
                  "element" : "a",
                  "attr" : {
                      "title" : "cancel",
                      "href" : "#",
                      "class" : "cancel"
                  },
                  "contains" : ""
              }]
          }
      }
      return structure;
  }
  </code></pre>