JSFiddle - React, Tailwind, and code Playground

HTML

<div></div>

JavaScript

(function(scope, name, undefined){
        scope[name] = function(selector){
            return new Plugin(selector);
        }
        
        function Plugin(selector){
            buildArrayLike(this, selector)
        }
        function buildArrayLike(obj, selector){
            var el = document.querySelectorAll(selector);
            for(var c = 0; c < el.length; c++) obj[c] = el[c];
            obj.length = el.length;
        }
        
        Plugin.prototype = {
            constructor : Plugin,
            method : function(){
                alert(this.length);
                return this; //For chaining;
            }
        }
    })(window, '$')
    
    
    
    console.log($('div'));
    
    $('div').method()