Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <script>
    
$(document).ready(function () {
  var MyConstructor = function () {};
  MyConstructor.prototype = {
    init: function () {
      //logs 'doing stuff'
      this.doStuff();
      //alias the prototype
      var mcp = MyConstructor.prototype;
      //another way of using proxy
      //more in line with the jQuery docs
      $('.my-element').click(function () {
        //actually a trivial example
        //could have done mcp.doStuff()
        //use to demonstrate proxy
        $.proxy(mcp.doStuff(), mcp);
      });
    },
    doStuff: function () {
      console.log('doing stuff');
    }
  };
  MyConstructor.prototype.init();
});
  </script>
  <p class="my-element">Some words.</p>
</body>
</html>
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers