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

407
Vistas
what is at() method in JavaScript?

Array.prototype.at()

what is .at() method in JavaScript?

const myList = ['index0', 'index1', 'index2']

myList.at(1) // 'index1'
mylist.at(-1) // 'index2'

there are many methods in js that similarly do this, why using this new method?

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

0

Yes, there are similar ways to get an element from an array or string, but at() will use a clear and easy syntax to get this.

give an index and return value

the principle is easy, just put your desire index and get value, if there isn't a value at this index, it returns undefined

for examples:

const myList = ['index0', 'index1', 'index2']

// to get latest item in the list using common ways:
const latestItem = myList[ myList.length - 1]

// using simpler approach with at()
const latestItem = myList.at(-1)

similarly, at() method will work fine with strings.

  • at the writing time of this post, at() will not be supported by some browser, you can find this here.
  • you can use polyfill if you want to use at() method in your codebase.
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