Javascript Image object without instantiating
- by user276027
This question is about javascript performance. Consider 3 examples for illustration:
function loadImgA() {
new Image().src="http://example.com/image.gif"
}
function loadImgA1() {
Image().src="http://example.com/image.gif"
}
function loadImgB() {
var testImg = new Image();
testImg.src="http://example.com/image.gif"
}
Now the point is I don't really need to manipulate the the image object after it was created, hence loadImgA(). The question is, what happens if nothing is assigned to the return value of the new Image() constructor - in that case I can actually skip the 'new' keyword as in loadImgA1()? Does the object then live outside the function or somehow affects memory usage? Other implications, differences? I reckon not, as no real instance was actually created?
To put this into perspective, I only need to get the http request for image through. No preloading or other advanced image manipulation. What would be the preferred method from the above?