Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
how to change `this` pointer in typescript

I want to create a Image data and rewrite onload function , but this can't point to newImage in typescript. what can i do to make this pointer point to newImage

enter image description here

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

You can tell TypeScript which type this should have by adding it as a function parameter:

function onload(this: HTMLImageElement) {
  const {width, height} = this
}

The parameter will be ignored when compiling to JavaScript.

See https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function

about 4 years ago · Juan Pablo Isaza Denunciar

0

According to the code you provided I do not see a way to use this pointer as newImg. But you will be able to use const{width,height} = newImg.somethingYouWannaDo().

about 4 years ago · Juan Pablo Isaza Denunciar

0

function onload(img){
  const {width, height} = img
}

Isn't onload passed the img?

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda