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

199
Vistas
Join elements of an object and exclude some

I have a Typescript project where I want to join all the values of an Object except one.

This is my Object:

let dataInit = {
  "host": "CAPR",
  "ua": "RMA",
  "country": "VE",
  "page":3
};

This is what I do:

let dataJoin = Object.values(dataInit).join(',')

This is what I get:

CAPR,RMA,VE,3

I need to know how to remove the 'page' property, this is what I want:

CAPR,RMA,VE
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

If you don't know the other attributes, you can first use Object.entries() to give you an array of arrays containing the keys and values. That array can then be filtered to remove the "page" element, mapped to just contain the value, and finally joined.

let dataInit = {
  "host": "CAPR",
  "ua": "RMA",
  "country": "VE",
  "page":3
};

console.log(
Object.entries(dataInit)
  .filter(([key,val]) => key !== "page")
  .map(([_,val]) => val)
  .join(",")
)

about 4 years ago · Juan Pablo Isaza Denunciar

0

I would destructure the object first and create a new one

const { host, ua, country } = dataInit
const dataNew = { host, ua, country }

And then call the values join method on the new object.

about 4 years ago · Juan Pablo Isaza Denunciar

0

You could filter the array resulted:

let dataJoin = Object.values(dataInit).filter(element => typeof element === "string").join(",");

Or you can use destructuring as presented in the other comments.

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