11
I have the following code:
var nomePropriedade = "Propriedade1";
var meuObjeto = {
    "nome" : "valor"
}
I would like the property name of meuObjeto received the variable value nomePropriedade.
Thus, when trying to access the properties of meuObjeto I would have to do:
meuObjeto.Propriedade1
And the return would be: "valor". That is, it would be the same as:
var meuObjeto = {
    Propriedade1 : "valor"
}
It is possible to do this?
Wallace, I’d just like to do a wake-up call,
hasOwnPropertywill return false if the property exists in the prototype and not in the object, in this case atypeof meuObjeto[nomePropriedade] !== 'undefined'It would work, certain that I doubt that the AP will need to use Constructors and Prototypes. You can see what I’m pointing at in this fiddle: https://jsfiddle.net/6nxmvsLx/– Tobias Mesquita