Could you propose any workarounds to implement a reference to variable using closures or any other tricks?
createReference = function() { // TODO: how to
You can't just promote x to be a reference.
x