Say I have an object such as this:
var time = {
'second': 1000,
'minute': 1000 * 60,
'hour' : 1000 * 60 * 60,
'day' : 1000 * 60 * 60 * 24,
'week' : 1000 * 60 * 60 * 24 * 7
};
How would I shorten it so it would reference the other keys?
I mean something like this:
var time = {
'second': 1000,
'minute': this.second * 60,
'hour' : this.minute * 60,
'day' : this.hour * 24,
'week' : this.day * 7
}
I can't reference each using time.foo
because the variable isn't initialized yet. I could simply add each on a new command, such as time['hour'] = time.minute * 60;
, but I'd rather do it in one command.