Quiero establecer dos propiedades iguales entre sí en un objeto. He aquí un ejemplo:Estableciendo dos propiedades iguales en la declaración
var obj = { // I want to do something like this
a: function() { ... },
b: alert,
c: a
};
Obviamente eso no funciona y tengo que hacer algo como esto:
var obj = {
a: function() { ... },
b: alert,
};
obj.c = obj.a;
¿Hay alguna manera de hacer eso en la declaración?
Ver http://stackoverflow.com/questions/2787245/how-can-a-javascript-object-refer-to-values-in-itself, http://stackoverflow.com/questions/4618541/can- i-reference-other-properties-during-object-declaration-in-javascript, y http://stackoverflow.com/questions/4616202/self-references-in-object-literal-declarations –