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

128
Views
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 answers
Answer question

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 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!