JSFiddle - React, Tailwind, and code Playground

by 1337

JavaScript

(function() { // Closure to not leak local variables to the global scope
        function f(a, b) {
          if ( !(this instanceof f) )
            return new f();    
            //Do something
        }
        // Prototype. All properties of f.prototype are inherited by instances of f.
        // An instance of f can be obtained by:    new f, new f(), Object.create(f)
        f.prototype.removeClass = function(a) {
            return a;
        };
        f.each = function(a) {
            alert(a);             
        };
        window.$ = f; // Publish public methods
    })();

    //Tests (these do not represent jQuery methods):
    $.each("Foo");                   // Alerts "Foo" (alert defined at $.each)
    alert($().removeClass('Blabla'));// Alerts "Blabla"