Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <script>
    (function() {
      var obj = {};
      // Define an ECMAScript5 property accessor
      // for the property 'a' on 'obj'      
      (function() {
        var _a;
        Object.defineProperty(obj, "a", {
          get: function() {
            display("get!");
            return _a;
          },
          set: function(value) {
            display("set!");
            _a = value;
          }
        });
      })();
      
      display("Doing <code>obj.b = obj.a = 42;</code>:");
      obj.b = obj.a = 42;
      display("Doing <code>obj.a = 42; obj.b = obj.a;</code>:");
      obj.a = 42;
      obj.b = obj.a;
        
      function display(msg) {
        var p = document.createElement('p');
        p.innerHTML = String(msg);
        document.body.appendChild(p);
      }
    })();
  </script>
</body>
</html>
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers