I have something like this:
function main() {
  function create_node() {
    console.log("create_node")
      (function() {
        var memo;
        console.log(memo);
        function f() {
          var value;
          console.log(value);
          if (memo) {
            value = memo.cloneNode();
            console.log("clone node");
            console.log(value);
          } else {
            var value = document.createElement("div");
            var style = "";
            value.setAttribute("style", style);
            value.innerHTML = "hello";
            console.log("new node");
            console.log(value);
          }
          return value;
        }
        return f;
      })();
  }
  var colection = [];
  for (var i = 0; i < 10; i++) {
    colection.push(create_node());
  };
}
main();the problem is I get an error (in firefox at least) while try to log "create_node". Also, if I don't return f(), instead of f, it doesn't get executed. In any case, memo is always undefined. So I have this three problems here. I guess they come from a lack of understanding on complex closures, so I'd need a Javascript rockstar to enlighten me!
 
    