utils/ts-src/hasOwn.ts
2022-10-21 12:08:36 +01:00

15 lines
357 B
TypeScript
Executable File

const hasOwnProperty = Object.prototype.hasOwnProperty;
/**
* Check if an object has an property
* @param obj The source object
* @param prop The required property
* @returns {boolean}
*
* @example
* U.hasOwn({bob:'1'}, 'bob') // => true
*/
export function hasOwn(obj: Object, prop: string): boolean {
return hasOwnProperty.call(obj, prop);
}