I'am trying make an array of object.
var number = 0;
var name = 1;
var dKeyObj = new Object();
//var dKeyPiar = new Object();
var dKeyPiar = [];
function sendFakeData() {
request(options, function (error, resp, body) {
dKeyObj['name'] = name.toString(16).padStart(2, '0'); // hexa value
dKeyObj['value'] = resp.headers['value'];
dKeyPair[number++] = dKeyObj;
console.log(dKeyPair[0]);
if(number < 99)
making();
else
//console.log('lasted data ' + dKeyPair[10]['name']);
console.log('lasted data ' + dKeyPair[10]);
});
}
I think the result is...
{ name: '01', value: 'the first value'}
{ name: '01', value: 'the first value'}
{ name: '01', value: 'the first value'}
...
//latest data 0a
latest data { name: '0a', value: 'the tenth value'}
But the log is...
{ name: '01', value: 'the first value'}
{ name: '02', value: 'the second value'}
{ name: '03', value: 'the third value'}
...
//latest data 63
latest data [object, Object]
The index of dKeyPair is ignored.
Can I make an array of object?