Any way to assign a variable (not an object property) another variable's value by reference in JavaScript? -


so, here's need:

var = 5; var b = a; = 6; alert(b) // want alert 6 not 5 

i've seen questions how variable assignment work in javascript?, answers https://stackoverflow.com/a/509614/1117796 , posts http://hpyblg.wordpress.com/2010/05/30/simulating-pointers-in-javascript/. not want use objects/hashes/dictionaries or whatever else want call them. want done plain variables containing plain primitive values. php assignment reference: $b = &$a;. @ possible? comes near it?

no isin't possible pass simple values reference in javascript.

however javascript flexible language , possibly implement similar using object.defineproperty providing setters , getters work same variable. work global variables however, there's no way mimic behaviour. instance, since can't reference execution scope of functions, not able emulate concept variables declared inside functions.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -