JSFiddle - React, Tailwind, and code Playground

by somekittens

JavaScript

// Determines if the function was called, and with what
// For testing purposes
var diedWithJSON = (function () {
    var called = false;
    // Nonsense here so if it's undefined, we know it was called with undefined, etc.
    var diedWith = 'snarglebots';
    return function (last) {
        if (!called) {
            diedWith = last;
            called = true;
            // So we can test if it *hasn't* been called
            return 'snarglebots';
        } else {
            return diedWith;
        }
    };
})();

// Problem is, I need to use this ~10x, and I'd like to just make copies.
// I thought this would work:
var diedCloneable = JSON.stringify(diedWithJSON); // Sadly, returns `undefined`

// How can I make deep copies of diedWithJSON?