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

262
Vistas
How to do [:] like in Python but in JavaScript?

in Python, you can get a list like this (array in JavaScript)

a = ["one", "two", "three"]
print(a[:]) # ["one", "two", "three"]

I'm wondering how I can do this too but in JavaScript. If it is possible, please tell me :)

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

0

In python, a[:] creates a shallow copy of the array. The equivalent in JS is [...a].

If you just want to get the first two elements, you can use a.slice(0, 2) which returns a new array. The slice method goes from the starting index (inclusive) to the ending index (non-inclusive).

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