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

172
Views
comprobando la propiedad vacía para una matriz de objetos

Quería verificar si hay una propiedad en una matriz de objetos que tiene un valor nulo, si es así, devuelve verdadero.

Actualmente mi problema es

 This condition will always return 'false' since the types '{ type: any; startDate: string; endDate: string; annualRent: any; }' and 'string' have no overlap.ts(2367)

#código actual para comprobar la propiedad vacía

 const hasEmptyRentSchedProperty = Object.values((this.proposedRentSchedule)).some((v => v === null || v === ""))

#object = this.proposedRentSchedule

 [ { "type": 0, "startDate": "2022-1-4", "endDate": "2022-1-19", "annualRent": "232" }, { "type": 0, "startDate": "2022-1-20", "endDate": "2022-1-20", "annualRent": null } ]
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La razón por la que obtiene ese error es porque está obteniendo los valores de la matriz cuyo tipo es { type: any; startDate: string; endDate: string; annualRent: any; } y no solo una string . En este caso, ¿cómo funciona una comparación de cadenas? Eso es lo que señala Typescript.

 var data = [ { "type": 0, "startDate": "2022-1-4", "endDate": "2022-1-19", "annualRent": "232" }, { "type": 0, "startDate": "2022-1-20", "endDate": "2022-1-20", "annualRent": null } ] console.log(data.some(element => Object.values(element).some(val => val === null || val === "")))

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!