How to use the hasOwnProperty attribute in js
This article mainly explains "how to use hasOwnProperty attribute in js". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian and go deep into it slowly to study and learn "how to use hasOwnProperty attribute in js" together.
js does not protect hasOwnProperty from illegal use, if an object happens to have this property, you need to use the external hasOwnProperty function to get the correct result.
When checking whether an attribute exists on an object, hasOwnProperty is the only method available.
examples
var foo = { hasOwnProperty: function() { return false; }, bar: 'Here be dragons'}; foo.hasOwnProperty('bar');//always returns false//use hasOwnProperty of other objects, and set its context to foo({}).hasOwnProperty.call(foo, 'bar'); // true Thank you for reading, the above is the content of "how to use hasOwnProperty in js". After studying this article, I believe everyone has a deeper understanding of how to use hasOwnProperty in js. The specific usage needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!