“HasownProperty.call” Ответ

Object.hashownproperty.call

const data = {
	a: 'a value'
}
// esnext, esm valid
const hasA = Object.hasOwnProperty.call(data, 'a'); // true
// browser, vanillajs, esnext, esm, commonjs
const hasA = data.hasOwnProperty('a'); // true
Dimas Lanjaka

HasownProperty.call

var foo = {
  hasOwnProperty: function() {
    return false;
  },
  bar: 'Here be dragons'
};

foo.hasOwnProperty('bar'); // always returns false

// Use another Object's hasOwnProperty
// and call it with 'this' set to foo
({}).hasOwnProperty.call(foo, 'bar'); // true

// It's also possible to use the hasOwnProperty property
// from the Object prototype for this purpose
Object.prototype.hasOwnProperty.call(foo, 'bar'); // true
Demolition

Ответы похожие на “HasownProperty.call”

Смотреть популярные ответы по языку

Смотреть другие языки программирования