JSFiddle - React, Tailwind, and code Playground

by userdude

JavaScript

function check(arg) {
    try {
        var func = new Function('return ' + arg + '()');
        
        console.log(typeof arg, this);
        console.log(func);
        console.log(func());
    } catch (e) {
        console.log(e);
    }
}

function run() {
    this.a = 1;
    
    function test() {
        console.log('Local test() run.');
    }
    
    check(test);
    check('test');
}

var r = new run();