Is it possible to declare variables in JavaScript inside an object declaration? I'm looking for something similar to
var myObject = {
myLabel: (var myVariable)
};
instead of having to write
var myVariable;
var myObject = {
myLabel: myVariable
};
EDIT
I want this in the context of Node.JS. This is what I have:
var server = {};
var database = {};
var moar = {};
module.exports = {
server: server,
database: databse,
moar: moar
};
doStuffAsync(function callback() {
// Populate variables
server = stuff();
database = stuff2();
});
module.exportsto your doStuffAsync function so that you can setserveranddatabasedirectly at that object?