How to simulate js variables “scope” behaviour

The name of the picture


How to simulate js variables “scope” behaviour



I'm looking for a library or hardcoded solutions to simulate the javascript behaviour of the script in var x = 0; form at run-time in Java.


var x = 0;



I've tried the classic ScriptEngine lib and other most known scripting compilers, but none of them does exactly the job I'm searching for.



The only result i've obtained is the compiling of the classic x = 0; scheme, till now.
My goal is to take Javascript statements and compile them in run-time as they are, respecting their visibility and lifetime (scope) they would have in a normal JS context.


x = 0;



Is there any way to do this or possible alternative work-around? Thanks





What's wrong with the ScriptEngine? how about rhino?
– Maurice Perry
4 hours ago




ScriptEngine









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Stripe::AuthenticationError No API key provided. Set your API key using “Stripe.api_key = ”

CRM reporting Extension - SSRS instance is blank

Keycloak server returning user_not_found error when user is already imported with LDAP