<p>I use the jQuery <a href="http://docs.jquery.com/Utilities/jQuery.extend" rel="nofollow noreferrer">extend</a> function to extend a class prototype.</p>

<p>For example:</p>

<pre><code>MyWidget = function(name_var) {
  this.init(name_var);
}

$.extend(MyWidget.prototype, {
   // object variables
   widget_name: '',

   init: function(widget_name) {
     // do initialization here
     this.widget_name = widget_name;
   },

   doSomething: function() {
     // an example object method
     alert('my name is '+this.widget_name);
   }
});


// example of using the class built above
var widget1 = new MyWidget('widget one');
widget1.doSomething();
</code></pre>

<p>Is there a better way to do this?  Is there a cleaner way to create the class above with only one statement instead of two?</p>

I quite like John Resig's
Simple JavaScript Inheritance
.
```
```
var MyWidget = Class.extend({
  init: function(widget_name){
    this.widget_name = widget_name;
  },

  doSomething: function() {
    alert('my name is ' + this.widget_name);
  }
});
```
```
NB: The "Class" object demonstrated above isn't included in jQuery itself - it's a 25 line snippet from Mr. jQuery himself, provided in the article above.