Working example with global var:
var example_var = 'global var example';
var x = function(){
var var_name = 'example_var';
alert('Global var value is: ' + window[var_name]);
}
How can I do same thing with a local variable? Like this (not working example):
var x = function(){
var example_var = 'Local var example';
var var_name = 'example_var';
alert('Local var value is: ' + window[var_name]);
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…