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
splice method only once

I have a stepper inside my application when user selects specific options on first step i want to splice some steps from my step array, but i have splice function on button, so everytime i go back and click button again it splices another item, how can i make it splice only once? here is my array of steps:

.ts

this.stepService.steps = [
  FirstStep,
  SecondStep,
  ThirdStep,
  FourthStep,
  SuccessPageComponent
];

nextStep() {

    let value = { ...this.form.value };
         if (value.type == 'once') {
          this.stepService.steps.splice(2, 1);
        }
    
        if (value.type == 'multiple') {
          this.stepService.steps.splice(1, 1);
        }

}
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use slice() instead.

splice() changes the original array, slice() doesn't but both of them returns array object.

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