Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am reading "Javascript : The good Parts" to improve my Javascript bases and knowledge. I was reading stuff about prototype and I encountered in this function :

var stooge = { ... } 
if(typeof Object.create !== 'function'){
   Object.create = function(o) {
   var F = function () {};
   F.prototype = o;
   return new F();
var another_stooge = Object.create(stooge);

I didn't really get the meaning and the benefit of creating this function.

share|improve this question
up vote 2 down vote accepted

It's only a shim for the standard Object.create function which isn't available in some browsers (yes, you guessed which one).

Note that it's not complete : it doesn't do everything that is done by Object.create but it's probably enough for the author.

As for why the author wanted to use Object.create instead of a explicit prototype based OOP, it's probably because it's a little simpler.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.