面试题答案
一键面试const obj = {0: 'a', 1: 'b', 2: 'c', length: 3};
const arr = Array.from(obj);
const asyncOperation = (element) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(element.toUpperCase());
}, 1000);
});
};
Promise.all(arr.map(asyncOperation))
.then(results => {
console.log(results);
});