Created
May 16, 2024 03:46
-
-
Save xinglongjizi/307370ac53edd2a5a7b7e0403f5b87e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @desc 判断`obj`是否为空 | |
| * @param {Object} obj | |
| * @return {Boolean} | |
| */ | |
| function isEmptyObject(obj) { | |
| if (!obj || typeof obj !== 'object' || Array.isArray(obj)) | |
| return false | |
| return !Object.keys(obj).length | |
| } | |
| module.exports = isEmptyObject | |
| /* | |
| 因此判断是否是对象 {} 的方式可以是: | |
| if (obj && typeof obj === 'object' && !Array.isArray(obj)) { } | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment