unknown: Neues JS-Objekt innerhalb eines Scopes?

Beitrag lesen

Bringen wir mal die lokale Variable noch mit unter, um zu zeigen, dass die immer zugreifbar ist(bei dir noch über eine Closure, aber das ist erst mal egal).
<html>
  <head>
    <title>test</title>
  </head>
  <body>
    <script type="text/javascript">
      var xxx = {
        xxx: "xxx",
        func: function()
        {
          var localVar = "localVar";
          alert(this.xxx);
          alert(this.yyy);
          alert(localVar);
        }
      }
      var yyy = {
        yyy: "yyy"
      };
      function getFunc(xxx)
      {
        return function() { xxx.func() };
      }
      yyy.func = xxx.func;
      yyy.func();
      alert("===jetzt mit Objektbindung===");
      yyy.func = getFunc(xxx);
      yyy.func();
    </script>
  </body>
</html>