Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

110
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda