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

241
Views
removing (slice? splice?) item from array based on index

I have an array that looks like this,

[
    "slug.current == 'current'",
    "parent->slug.current == 'parentSlug'",
    "parent->parent->slug.current == 'parentParentSlug'",
    "parent->parent->parent->slug.current == 'parentParentParentSlug'"
]

This is created via this code,

path.split('/')
    .filter(i => i)
    .reverse()
    .map((slug, i) => {
      return `${'parent->'.repeat(i)}slug.current == '${slug}'`;
    });

I am wanting to remove the "parent->slug.current == 'parentSlug'" from ever being the error I would like to disregard after the split if possible,

I though it would need to something like,

path.split('/')
        .filter(i => i)
        .reverse()
        .splice(2, 2)
        .map((slug, i) => {
          return `${'parent->'.repeat(i)}slug.current == '${slug}'`;
        });

This returns the below,

[
    "slug.current == 'current'",
    "parent->slug.current == 'parentSlug'"
]

when what I want is,

[
        "slug.current == 'current'",
        "parent->slug.current == 'parentParentSlug'",
        "parent->parent->slug.current == 'parentParentParentSlug'"
    ]
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

change splice to this

.splice(1,1)

first argument is the index, second one means how many items after this index should be deleted (including the index it self)

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!