JSFiddle - React, Tailwind, and code Playground

by bogdan_vq

JavaScript

function func(){
    
    var context_field = "context_field";
    var context_method = function(){
        console.log("context method");
    };
    
    console.log("init func method");
    func = function(param, change){
        if(typeof(change) === 'undefined'){
            console.log("Func has other reference.");
            console.log(param + " " + context_field + " from original func - closure.\n\n");
        }else{
            console.log(param + " " + context_field + " from original func - closure.");
            console.log("What happend with context_method from original func ?");
        }
        return context_method;
    }
    return func;
};

func()("Init finished and call");
func("Call again", "")();