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

131
Visualizações
hasOwnProperty returns false But The object that seems to have properties?

My JSON.stringify return empty object notation "{}" for an object that seems to have properties?

And hasOwnProperty returns false But The object that seems to have properties?

This is my properties

enter image description here:-

My JSON.stringify code:-

 const locals =JSON.stringify(action.data.displayNameLocalization);
 console.log( locals);

If my object have properties,hasOwnProperty() return false.

const test=action.data.displayNameLocalization;
console.log(test);
console.log(test.hasOwnProperty());

enter image description here

Result:-

enter image description here

I have no idea what is happening...? Anyone can help men with this..?

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

0

The hasOwnProperty() method returns a boolean indicating whether the object has the specified property as its own property (as opposed to inheriting it) so you should pass a property name when using this function.

Note, that you can use the new Object.hasOwn() static method which returns true or false indicating if the specified object has the indicated property as its own property (yet it is still not supported by all browsers)

const test = {ch : 'China', fr: 'Franch'};
console.log(test.hasOwnProperty('ch')); // checking if the property `ch` is an own property
console.log(test.hasOwnProperty()); // checking for undefined..

console.log(Object.hasOwn(test, 'ch')); // using the new Object.hasOwn method

More about hasOwnProperty - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty

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