I'm sorry if my vocab is misleading in the question, but essentially I want to use a variable as the value of a property within one javascript object. For example:
var fruits = {
banana: 'yellow',
apple: 'red',
jazz_apple: apple
}
If I define a function and call this, I can access the value no problem, i.e.
var fruits = {
banana: 'yellow',
apple: 'red',
jazz_apple: function() {
return this.apple //fruits.jazz_apple() returns 'red'
}
}
But I don't want to define a function to get this value. Is there a way to reuse the previously declared color for fruits.apple ('red') on the new property fruits.jazz_apple within the object without a function?