Howto create a jquery-like $() wrapper function?
<p>I'm creating a small code plugin which allows you to do some things with arrays. I do not wish to add the functions to the array object using a prototype construction, what I want is that people can do something like:</p>

<pre><code>arrayFunction( [1, 2, 3] ).someSpecialArrayFunction();
</code></pre>

<p>Thus leaving the normal array object unaltered.<br />
So I came up with the following construction (which was inspired on the jQuery source code) :</p>

<pre><code>var arrayFunction = window.arrayFunction = function(array) {
    return new arrayFunction.fn.init(array);
}
arrayFunction.fn = arrayFunction.prototype = {
    init: function(array){
        this.a = array;
        //should I return something here?
    },
    someSpecialArrayFunction: function(){
        //Super cool custom stuff here.
    }
}
</code></pre>

<p>However this does not work (obviously). What should happen in the init function()?</p>

<p>The error right now is that when I try:</p>

<pre><code> arrayFunction(array).someSpecialArrayFunction();
</code></pre>

<p>it says that someSpecialArrayFunction() is not a function?</p>

<p>How should one do this?</p>

<p><B>edit</b><br />
Yes, this is indeed a simpliefied example. The actual thing has way more methods.</p>

<p>Also, I just though of how awesome it would be if it also supported chaning, how would you do that?</p>
