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

189
Vistas
how can create function anonymous javascript whit arguments this

I'm trying to perform an anonymous function with a this-type argument, with the aim that an element of DOM can occupy it.

javascript: (this is dynamically created at run time)

const example = function(this) { return this }

html:

<button onclick="example(this)" ><button>

result:

Uncaught SyntaxError: Unexpected token 'this'

how can I do it?, thanks!

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

0

As mentioned in the comments, this is a special keyword in JavaScript; when you call an object method, this contains the object that the method was called through.

Just use another variable name.

const example = function(el) { console.log(el.innerText); };
<button onclick="example(this)" >Click me</button>

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