I am trying to create the following nested object inside a for loop using JavaScript which then gets pushed to an existing array:
_spec = {
_key: {
type: _clHndl.getFieldType(_f),
editable: true,
validation: {
required: _clHndl.isRequired(_f),
min: 10
}
}
};
_arr.push(_spec);
The _key field is dynamic (changes every iteration), I want the identifier of the nested item _key to be the actual value that _key contains in the iteration. Right now it just makes each one '_key' when I use JSON.stringify() to inspect it.
Any help would be appreciated. Thanks for your time.
spec
object, so it'll be the same as most other examples given.spec = {}; spec[my_dynamic_key] = {type:...};
– squint Jul 5 '12 at 13:34