While defining an object in javascript, is there a way for a member of that object to access the value of another member of the same object? For example if I am defining the below (using jquery)
var x = $.extend({}, {
greeting: 'hello',
message: this.greeting+' world'
});
alert(x.message);
This above code would alert undefined world
. How do I make it take the value of greeting
during the definition. In this case the expected output is hello world
.