showing results for - "hasownproperty call"
Amelie
22 Jun 2017
1var foo = {
2  hasOwnProperty: function() {
3    return false;
4  },
5  bar: 'Here be dragons'
6};
7
8foo.hasOwnProperty('bar'); // always returns false
9
10// Use another Object's hasOwnProperty
11// and call it with 'this' set to foo
12({}).hasOwnProperty.call(foo, 'bar'); // true
13
14// It's also possible to use the hasOwnProperty property
15// from the Object prototype for this purpose
16Object.prototype.hasOwnProperty.call(foo, 'bar'); // true