例如:
let array2 = [[{"Aaa":111}],[{"bbb":222}],[{"ccc":333}]];
我是初学者,如何将其变成?
[{"Aaa":111},{"bbb":222},{"ccc":333}]
答案 0 :(得分:0)
您可以尝试像这样映射它:
array2 = array2.map(i=>{
return i[0]
})
答案 1 :(得分:0)
您可以像这样使用javascript async promise
函数:
const net = require('net');
const HOST = 'linux345';
const PORT = 2345;
let ErrCode = 1;
const client = new net.Socket();
client.connect(PORT, HOST, function() {
ErrCode = 0;
});
client.on('data', function(data) {
console.log('Client received: ' + data);
if (data.toString().endsWith('exit')) {
client.destroy();
}
});
client.on('close', function() {
});
client.on('error', function(err) {
ErrCode = err.code;
console.log(ErrCode);
});
console.log(ErrCode);