JSFiddle - React, Tailwind, and code Playground

by nickadeemus2002

JavaScript

MyObject=function(){};

    MyObject.doSomething = function() {
        console.log("MyObject->doSomething: I do as I am told.");
    }

    var anotherObject = new MyObject();
    
    anotherObject.doSomething = function() {
       console.log("anotherObject instance method -> I do the bare minimum required of me!");
    }

    anotherObject.doSomething(); //calls the instance specific method
    
    MyObject.doSomething(); //calls the static Object method
    MyObject.prototype.doSomething = MyObject.doSomething; //apply the static method to all instances from here on in
    anotherObject.doSomething(); //still calls the instance method
   
    var yetAnotherObject = new MyObject();
    yetAnotherObject.doSomething(); //inherited doSomething() from MyObject
    MyObject.doSomething(); //pre-existing instances also inherit the new function