When working with JavaScript, I came across a situation where I am not sure that what I'm trying to do is possible:
Given the following object:
var data = {};
Is it possible to change the "data" so that when it is expanded as follows:
data.entry_1 = { 'prop_1': 'set_1', 'prop_2': 'set_2' };
the new property is automatically bound to the new object, i.e.
data.entry_1 = { 'prop_1': 'set_1', 'prop_2': 'set_2', id: 1 // automatically created property };
Is it possible to do the above without using "external" methods, for example. no data.newEntry (object)?
source share