Image()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Constructor del elemento de Imagen

Acepta dos parametros opcionales: Image([unsigned long width, unsigned long height])

Devuelve un HTMLImageElement instanciado justo como document.createElement('img') would.

Ejemplo:

js
var myImage = new Image(100, 200);
myImage.src = "picture.jpg";
console.log(myImage);

Resultado:

html
<img width="100" height="200" src="picture.jpg" />
Specification Status Comment
HTML5 La definición del constructor de imagen, en esta especificación. Recommendación Un constructor (con 2 parametros opcionales) han sido agregados. Las siguientes propiedades ahora son obsoletas: name, border, align, hspace, vspace, and longdesc. The following properties are now unsigned long, instead of long: height, and width. Las siguientes propiedadeas ahora han sido agrgados: crossorigin,