I'm afraid I probably can't help you, then, since I'm so new to JavaScript-- my only suggestion would be to try the other, longer syntax suggested in those comments:
var jsVariable = cp.variablesManager.getVariableValue('myCpVar');
But I don't know how that'd make a difference, especially if you got the set variable command to work... Hopefully a JavaScript guru will be able to help you. Image may be NSFW.
Clik here to view.