Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to get the variable by it's name using Javascript

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 173
    Comment on it

    Hello Reader's, Suppose you having a variable and you want to find it by it's name, See the example below:-

    var MyVar = '12';
    alert(window['MyVar']);
    

    Output:-

    12
    

    No if you have variable like this way

    var MyVar = {IND:'value12'};
    alert(MyVar['IND']); 
    

    Output:-

    value12
    

    So now like these way you can find the variable by their name

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: