Posted By

ericmuyser on 03/31/11


Tagged

js


Versions (?)

Object.create


 / Published in: JavaScript
 

  1. if (typeof Object.create != 'function') Object.create = (function() {
  2. function Subclass() {}
  3. function create(object) {
  4. var result;
  5. if (!(typeof object == 'object' && object && arguments.length == 1)) throw new TypeError();
  6. Subclass.prototype = object;
  7. result = new Subclass();
  8. Subclass.prototype = null;
  9. return result;
  10. }
  11. return create;
  12. }());

Report this snippet  

You need to login to post a comment.