Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

JavaScript does not protect the property name hasOwnProperty

// hasOwnProperty – JavaScript does not protect
var foo = {
    // overriding foo's default hasOwnProperty method
    hasOwnProperty: function() {
        return false;
    },
    bar: 'data'
};
foo.hasOwnProperty('bar'); // false always

// Hence, to prevent this, use Object.prototype.hasOwnProperty as follows-
Object.prototype.hasOwnProperty.call(foo, 'bar'); // true
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to close modal using esc key in nuxt js 
Javascript :: how to revers bulain in js 
Javascript :: js class method called when page loads 
Javascript :: object notation and array notation dynamic class binding vuejs 
Javascript :: launch.json for debug vuejs in vcsode 
Javascript :: render image url in react native 
Javascript :: jquery give control focus 
Javascript :: how to get cwd nodejs 
Javascript :: width 100% react native 
Javascript :: remove file from input type file jquery 
Javascript :: js contains class 
Javascript :: javascript match number 
Javascript :: how to check if iframe is loaded 
Javascript :: map through keys javascript 
Javascript :: modulo do angular httpclient 
Javascript :: can butterfly read english 
Javascript :: regular expression javascript with domain validation 
Javascript :: javascript add class to all child elements 
Javascript :: if json valide js 
Javascript :: effect jquery 
Javascript :: regExp for finding a first letter and last letter in a string 
Javascript :: what is the difference beetween += and =+ 
Javascript :: laravel ajax form submit 
Javascript :: regex for no whitespace at the beginning and end 
Javascript :: js compare lists 
Javascript :: javascript move element in array 
Javascript :: wordpress add jquery script 
Javascript :: angular module with routing cli 
Javascript :: jquery add html to end of div 
Javascript :: mongodb create database with username and password 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =