What I like to do to return multiple values is just return an object.
So using your example, you would:
let image = new Image();
let myImage = {};
image.onload = function (dimensions) {
var width = dimensions.width;
var height = dimensions.height;
//Option A (move your "constructor code" to another function)
createResolution(width, height)
//Option B
myImage.width = width;
myImage.height = height;
};
image.src = URL.createObjectURL(image);
function createResolution(width, height) {
//Here you can store the dimensions
myImage.width = width;
myImage.height = height;
});
This more so looks like what you are trying to accomplish:
let image = new Image();
function createResolution (dimensions) {
this.width = dimensions.width;
this.height = dimensions.height;
};
image.onload = createResolution;