I have a Javascript object that looks like this.
ips[ipID] = {}
So I end up with a bunch of ips that need to store information that will look like
ipID { name : 'val', anotherName : 'anotherVal' }
My question is, how do I dynamically add these names and values?
I believe this is the easiest thing to do if your names are dynamic:
var myobj = {}; var newFieldName = 'my new field name'; var newFieldValue = 'my new field value'; myobj[newFieldName] = newFieldValue;
var ipID = {}; ipID.name = 'val'; ipID.anotherName = 'anotherVal';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With