Answer the question
In order to leave comments, you need to log in
How to remove an array element returned by a function?
Good afternoon, there is a function that returns a promise with an array of numbers.
How to remove an element from the result in an async function without additional variables?
async function a(): Promise<number[]> {
return [1, 2, 3];
}
async function b(): Promise<void> {
const tmp = await a();
const result = tmp.shift();
// что-то с result
}
Answer the question
In order to leave comments, you need to log in
async function a(): Promise<number[]> {
return [1, 2, 3];
}
async function b(): Promise<void> {
const [shift, ...result] = await a();
// что-то с result
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question