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

143
Vistas
How do you understand WebStorm's function interfaces?

I am having trouble understanding some functions, and their interfaces. IE:

ReadonlyArray<unknown>.map( 
    callbackfn: (value: unknown, index: number, array: unknown[]) => unknown,
    thisArg?: any): unknown[]

This is what WebStorm displays when I hover over a .map() function. I understand that .map() takes a specified callback function as a parameter, but what do => unknown, and thisArg?: any represent?

Likewise when I hover over a forEach() function, the popup looks like this:

ReadonlyArray<unknown>.forEach(
     callbackfn: (value: unknown, index: number, array: unknown[]) => void,
     thisArg?: any): void

forEach also takes a callback function as a parameter, but what does => void, thisArg?: any): void represent?

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

0

// the `.map` function is member of the generic type ReadonlyArray<unknown>. Where unknown is the type of the elements of the array
ReadonlyArray<unknown>.map( 
    // first argument is a callback function. The first argument of the callback is value, of type unknown, the second is index of type number, and so on
    callbackfn: (value: unknown, index: number, array: unknown[]) 
       // this parts means that the callback should return a value of type unknown
       => unknown,
    // .map takes a second arguments called thisArg of any type. The ? means that the argument is optional
    thisArg?: any)
    // .map returns an array of type unknown
    : unknown[]

The type is unknown because it depends on the type of the elements present in the array on which .map is applied. If it is an array of object, the unknown type will be object

Similarly, forEach takes a first argument which is a callback. But the callback returns nothing, hence you have => void.

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