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

192
Vistas
Using Array.at(index) instead of Array[index] in JavaScript

I have a question about Array.at() method that was introduced Array.prototype.at() - MDN. It seems more useful than squared brackets annotation arr[i] since there is an option to specify index starting from the end of an array, for example: arr.at(-1) which would return the last member of arr array. Also, it seems more appropriate for method chaining. Are there any downsides to switching to it?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

A couple of disadvantages to it are:

  • It's a very new method. Older browsers will not be able to understand your code if you use it, unless you include a polyfill - so make sure you include one..
  • On a completely different track, since it's such a new method, I wouldn't be surprised if a substantial number of developers haven't heard about it - using .at may confuse some of them (and cause them to have to look it up). Not that this means that you shouldn't use it, but it's something to keep in mind.
over 4 years ago · Santiago Trujillo Denunciar

0

Another disadvantage that code can redefine this function. This may be a security concern

Array.prototype.at = () => console.log("🔥"); 
over 4 years ago · Santiago Trujillo Denunciar

0

The Array.at() method is under experiment at present and it might get change as developers around the world will test and create loopholes, ofcourse.

Though, you can use the polyfill and things get easy for you as any future change on the experiment will not affect your code and it will not break apart.

Also, the method might work with both () and [] which is a quite confusing thing. It is mentioned in the mozilla official docs as: This is not to suggest there is anything wrong with using the square bracket notation.

So, it is not recommendable to use array.at now.

enter image description here

over 4 years ago · Santiago Trujillo 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