JSFiddle - React, Tailwind, and code Playground

HTML

<html>    
    <body>
        <input name="Red" class="color"/>
        <input name="Blue" class="color"/>
        <input name="Green" class="color"/>
    </body>
</html>

JavaScript

(function($) {
    $.fn.collect = function(callback) {
        if (typeof(callback) == "function") {
            var collection = [];

            $(this).each(function() {
                var item = callback.apply(this);

                if (item)
                    collection.push(item);
            });

            return collection;
        }

        return this;
    }
})(jQuery);

var inputs = $("input.color").filter(function(){return true;});
alert("This is what returned by filter: " + inputs);

var colors = $("input.color").collect(function(){return this.name;});
alert("This is what returned by collect: " + colors);