javascript mixins

using the apply method to do javascript mixins

by derickbailey

HTML

<div id="results"></div>

JavaScript

function Stuff() {
  this.whatever = function(){
    $("#results").append("whatever was called. ");
  }

  // ... other stuff here
}

foo = {};
Stuff.apply(foo);

foo.whatever();

bar = {};
Stuff.call(bar);

bar.whatever();