Skip to content

How to get a value declared using const? #1050

Answered by lahma
Tacodiva asked this question in Q&A
Discussion options

You must be logged in to vote

GetValue resolves from object's properties, in this case from global environment's variable environment (which is basically the global object). You need to use Evaluate get access items seen by script, in this case the lexical environment which contains let/const/class.

Console.WriteLine(new Engine().Execute("const x = 10;").Evaluate("x")); // 10

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Tacodiva
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants