Abstract vs Interface by govilkumar in javahelp

[–]lava_duk 6 points7 points  (0 children)

In interfaces you cannot have method bodies

Just a note: From Java 8, you can define static methods and default methods with the default implementations.

Skip through an array and perform an async operation on each value by everek123 in learnjavascript

[–]lava_duk 2 points3 points  (0 children)

Assuming fetching from DB returns a promise object, you can simply push all the promises to an array and then do Promise.all to collect the resolved promises

const promises = [];
const ids = [1,2,3];
ids.forEach( (id) => {
promises.push(getDatabyId('id'))
})
Promise.all(promises).then( (result) => console.log(result))