UNPKG

bixi

Version:

企业级中后台前端解决方案

24 lines (22 loc) 623 B
/** Used to check objects for own properties. */ const hasOwnProperty = Object.prototype.hasOwnProperty; /** * Checks if `key` is a direct property of `object`. * @param object The object to query. * @param key The key to check. * @returns Returns `true` if `key` exists, else `false`. * @see hasIn, hasPath, hasPathIn * @example * * const object = { 'a': { 'b': 2 } } * const other = create({ 'a': create({ 'b': 2 }) }) * * has(object, 'a') * // => true * * has(other, 'a') * // => false */ export function has(object: object, key: string) { return object != null && hasOwnProperty.call(object, key); }