Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

116
Views
Mover el primer elemento de la matriz para que sea el último

Resultado:

ingrese la descripción de la imagen aquí

Código:

 window.dataLayer = window.dataLayer || []; window.dataLayer.push({ 'event': 'clientId', 'clientId': SlicedCookie });

Pregunta: ¿Cómo muevo '0' para que sea el último elemento de la matriz?

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

shift el primer elemento y push hasta el final.

 const arr = [1, 2, 3, 4]; arr.push(arr.shift()); console.log(arr);

about 4 years ago · Juan Pablo Isaza Report

0

Después de tener la matriz completa, haga esto para mover el primer elemento al último:

 window.dataLayer.push(window.dataLayer.splice(0,1)[0]);
about 4 years ago · Juan Pablo Isaza Report

0

No elimino su ejemplo, pero según tengo entendido, podría usar Array.prototype.splice y Array.prototype.push para lograr este requisito.

 const data = [2, 3, 4, 5]; const item = data.splice(0, 1); data.push(item[0]); console.log(data);

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!