How does jQuery’s .text() work, internally?
<p>I quickly tried to find the implementation in jQuery’s source, but only found <a href="https://github.com/jquery/jquery/blob/61e37d41490aed319a176c6ca7feb95e5505059c/src/manipulation.js#L33-46" rel="nofollow">this</a> which doesn’t actually seem to define it completely.</p>

<p><strong>From the jQuery Source</strong></p>

<pre><code>jQuery.fn.extend({
    text: function( text ) {
        if ( jQuery.isFunction(text) ) {
            return this.each(function() {
                return jQuery(this).text( text.call(this) );
            });
        }

        if ( typeof text !== "object" &amp;&amp; text !== undefined ) {
            return this.empty().append( (this[0] &amp;&amp; this[0].ownerDocument || document).createTextNode( text ) );
        }

        return jQuery.getText( this );
    },
</code></pre>

<p>Anyone know?</p>

<p><strong>Clarification:</strong><br>
I know how to <em>use</em> it. I just want to know how to get the text of an element à la jQuery when jQuery isn’t available.</p>
