Monday, 5 June 2017

How to use variable as object property in javascript [duplicate]

This question already has an answer here:

I have this simple code here where i'm trying to use a variable's value to set the key of an object. However it does not use the value and treats the variable as a new object or so.

Here's the code

            var engz = 'English';
            var key = [
                [{engz : {} }]
                [{'Spanish' : {} }]
            ];
            ctx.keyboard(key);

On the keyboard, i get just 'engz' instead of 'English'.



via Haider Ali

No comments:

Post a Comment