javascript - How to get the scope from where a function was called? -


i'm trying create javascript expression parser, able parse expression , declared variables in body, without executing function:

function test(expressionfn) {    var expression = getexpression(expressionfn);    // value expression.expressionright in scope    // not work -> var valuerigthinscope = expressionfn.prototype.constructor[[[scopes]]][expression.expressionright];    console.log(expressionfn.prototype); // see ".constructor[[[scopes]]]" in debug tools [f12]  }    function getexpression(expressionfn) {    var strafterreturn = expressionfn.tostring().split("return")[1].trim();    let strexpression = strafterreturn.split(";")[0].split(" ");    return {        expressionleft: strexpression[0],        operator: strexpression[1],        expressionright: strexpression[2]    };  }    function start(){  	var myvalue = "this value!";  	test(function(x) { return x.prop1 == myvalue; });  }    start();
<h1>see console</h1>

example in jsfiddle.

but can not access scope of function value of variable myvalue, example.

in google chrome console managed through function scope variable myvalue declared, can not access same scope in javascript.

follows image of google chrome console:

enter image description here

how can access [[scopes]] in image?


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -