Spaces:
Sleeping
Sleeping
File size: 585 Bytes
61d39e2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/**
* Instead of `myObject.hasOwnProperty(k)`, always write:
* `safeHasOwnProperty(myObject, k)`.
*
* This is a less verbose way to call `Object.prototype.hasOwnProperty.call`.
* This prevents unexpected behavior when `hasOwnProperty` is overridden,
* which is especially possible for objects parsed from user-sent JSON.
*
* explanation: https://eslint.org/docs/latest/rules/no-prototype-builtins
* @param {*} o
* @param {...any} a
* @returns
*/
export const safeHasOwnProperty = (o, ...a) => {
return Object.prototype.hasOwnProperty.call(o, ...a);
};
|