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

108
Views
How to loop through an array and remove objects with ... in javascript

I'm trying to return results to frontend from backend but would like to remove some of the data taken from the query.

I'm currently able to remove it for the first object in the array but would like to do it for every object.

const { url, booking_created, booking_date, student_id, student_name, ...sendEvent} = bookedSlots[0]

sending sendEvent returns

{
    "id": 1,
    "start": "2022-09-28T19:00:00.000Z",
    "end": "2022-09-28T20:00:00.000Z",
    "duration": "60MIN",
    "title": "1 hour lao lessons",
    "tutor_id": "901"
}

I'm not sure how to loop through the object and apply this to everything.

{
    "0": {
        "id": 1,
        "booking_created": "2022-09-24T19:49:00.000Z",
        "booking_date": "2022-09-24T00:00:00.000Z",
        "start": "2022-09-28T19:00:00.000Z",
        "end": "2022-09-28T20:00:00.000Z",
        "duration": "60MIN",
        "student_id": 1,
        "student_name": "Bob the builder",
        "title": "1 hour lessons",
        "url": "nan",
        "tutor_id": "901"
    },
    "1": {
        "id": 2,
        "booking_created": "2022-09-24T20:25:15.000Z",
        "booking_date": "2022-09-24T00:00:00.000Z",
        "start": "2022-09-28T21:00:00.000Z",
        "end": "2022-09-28T22:00:00.000Z",
        "duration": "60MIN",
        "student_id": 1,
        "student_name": "Big boss 1",
        "title": "1 hour lessons",
        "url": "nan",
        "tutor_id": "901"
    },
    "2": {
        "id": 3,
        "booking_created": "2022-09-28T12:00:13.000Z",
        "booking_date": "2022-09-08T00:00:00.000Z",
        "start": "2022-09-28T18:00:00.000Z",
        "end": "2022-09-28T19:00:00.000Z",
        "duration": "60MIN",
        "student_id": 1,
        "student_name": "bobo",
        "title": "bob lesson",
        "url": "123",
        "tutor_id": "901"
    }
}
almost 4 years ago · Santiago Trujillo
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!