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

175
Views
using array.splice with for loop dose not delete all the array elements
    let arr = [10,20,30];
    
        for(let i = 0 ; i<arr.length;i++){
            arr.splice(i,1);
                console.log(`i = ${i}   and arr indexs  are ${arr.indexOf(arr[i])}`);
        }
    
            console.log(arr);

the output is :
i = 0   and arr indexs  are 0
i = 1   and arr indexs  are -1
[20]
and I want the output to be like:
i = 0   and arr indexes  are 0
i = 1   and arr indexes  are 1
[]

the splice function does not delete all elements of the array and I want all the elements to be deleted

about 4 years ago · Juan Pablo Isaza
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!