Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

171
Visualizações
Function empty object check

enter image description here

I need help this task You have to implement function that will Check that object is empty. Object considered to be empty when it has no properties or all its properties are false (I.e. 0, “”, false …)

check object for presence: {},0, “”, symbol(“key”), null, 5,[].

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You can use something like this. This will just loop through the object and check if any value exist and if it does it will just return false else it will return true.

function isEmpty(obj) {
  for (let key in obj) {
     if(!!obj[key]) return false;
   }
   return true;
}
about 4 years ago · Juan Pablo Isaza Relatório

0

You can use 'Object.Values(obj)' which returns an array of all the values from the key value pairs of the object passed as parameter.

'!Object.Values(obj)' will return false if there are no values, which means this is not an object.

'anArray.every(element => { //return a boolean } )' will loop through all the items of the array and return true only if the the arrow function returns true for all 'every' element on the array

function isEmpty (obj){
    return !Object.Values(obj) ||
    Object.Values(obj).every (v => !v));
    
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda