JSFiddle - React, Tailwind, and code Playground

by spechackers

JavaScript

function A() {}
    A.prototype.x = 10;
    
    var a = new A();
    alert(a.x); // 10
    
    var newPrototype = {
      x: 20,
      y: 30
    };
    A.prototype = newPrototype; //will fail
    alert(a.y) // undefined

    a.__proto__ = newPrototype; //will work
    alert(a.x);
    alert(a.y);