Which method of creating javascript objects is better?
<p>I've seen objects defined in two different ways, which function similarly, but are, of course, fundamentally different. You can do it either like this:</p>

<pre><code>var myobject = {property: 'hello',
                act: function() {
                    this.property += ' world';
               }};
</code></pre>

<p>and like this:</p>

<pre><code>function myobject() {
    this.property = 'hello';
    this.act = function() {
        this.property += 'world';
    }
}
</code></pre>

<p>The second method could create objects like so</p>

<pre><code>var newobj = new myobject();
</code></pre>

<p>but you could do something similar using the first notation by making the object the return value of a function. The new keyword has the advantage of being able to pass parameters that can be used to initialize the properties of the object, but you could just as easily add an init function to the first kind of object.</p>

<p>Just wondering if besides these two differences, if there was a fundamental difference that made one method definitely better than the other method.</p>
