Check if images are loaded (ES6 Promises)
Well, you normally don't want to use the Promise constructor in your higher level code, you want to Promisify as low as possible. So let's create a function that checks for a single image, and resolves whenever you know the status of that image:

// When there's only one statement, you can drop the {} and the return
// x =&gt; y is equivalent to x =&gt; { return y; }
const checkImage = path =&gt;
    new Promise(resolve =&gt; {
        const img = new Image();
        img.onload = () =&gt; resolve({path, status: 'ok'});
        img.onerror = () =&gt; resolve({path, status: 'error'});

        img.src = path;
    });


Now, with that Promise returning action, we can do some fancy things:

const loadImg = paths =&gt; Promise.all(paths.map(checkImage))


Or, if you want to get fancier

const loadImg = (...paths) =&gt; Promise.all(paths.map(checkImage));
// and call with
loadImg('path1', 'path2', 'path3');
// or
loadImg(...arrayOfPaths)




It's perfectly fine to not reject if there's no error. Yes, there was an error loading the image, but it isn't an exceptional situation, it's not something you'd throw because of. Your function is actually there to check if the image loaded fine or not.