How to emulate a constructor with ES5 Object.create and object literal syntax?
<p>Presume I have an object like this:</p>

<pre><code>var Foo = {
  x: 5,
  sprite: new Image()
}
</code></pre>

<p>Problem: I want to initialize that sprite with the right src.  However, when I use the following creation technique:</p>

<pre><code>var f = Object.create(Foo);
</code></pre>

<p>I don't have a constructor method (aka init function) to setup <code>sprite.src = 'cool.png';</code></p>

<p>My question:</p>

<p>If I am using the object literal technique, and <code>Object.create()</code>, when do I actually initialize some of my internal state (like the example of the <code>new Image()</code>)</p>

<p>My solution:</p>

<pre><code>var Foo = {
  create: function() {
    var f = Object.create(Foo);
    f.sprite.src = 'cool.png';
    return f;
  }
}
</code></pre>

<p>However, I don't know if that's a great pattern.  I'd like to do this the "JavaScript Way" if there is a way. :)</p>

<p>Thanks!</p>
