1 Star 0 Fork 0

UnPourTous/lodash

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
has.js 685 Bytes
一键复制 编辑 原始数据 按行查看 历史
John-David Dalton 提交于 2017-02-27 15:07 +08:00 . Simplify has and hasIn.
/** Used to check objects for own properties. */
const hasOwnProperty = Object.prototype.hasOwnProperty
/**
* Checks if `key` is a direct property of `object`.
*
* @since 0.1.0
* @category Object
* @param {Object} object The object to query.
* @param {string} key The key to check.
* @returns {boolean} 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
*/
function has(object, key) {
return object != null && hasOwnProperty.call(object, key)
}
export default has
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/UnPourTous/lodash.git
git@gitee.com:UnPourTous/lodash.git
UnPourTous
lodash
lodash
master

搜索帮助