Hi Khushbu,
While this is a public function, it is not currently marked for name preservation, so you'll have to use an unminified version of the jsinterpreter (clone the repo and build yourself).
Warning: this function is not sufficiently protected for bad input. varName must be a previously defined variable name, or things will blow up in very bad ways.
To that point, Blockly sometimes needs to rename variables when generating a script (for example to avoid conflict with a language's keywords; you can't have a javascript variable named
var). If you're using
developer defined variables, I presume this isn't be an issue since you'll choose valid js variables.
Unfortunately, for user variables, we haven't kept a mapping of Blockly variables to the variable names in the code. The closest we have is the
defvars list inside
Blockly.JavaScript.init(). You could rework
this loop to create a map of variable id to JS variable name, though the details may change in future versions of Blockly. The variables code is still settling down after the introduction of variable types.