当前位置:网站首页>js判断对象是否为空
js判断对象是否为空
2022-07-02 06:23:00 【xuefankang】
1、es6中可以使用Object.keys(obj)
var obj= {};
var arr = Object.keys(obj);
alert(arr.length == 0); //true 为空, false 不为空2、将json对象转化为json字符串,再判断该字符串是否为"{}"
var obj= {};
var b = (JSON.stringify(obj) == "{}");
alert(b); //true 为空, false 不为空
边栏推荐
- Common function writing method and set get writing method for calculating attributes
- 构建学习tensorflow
- Virtualenv and pipenv installation
- unittest.TextTestRunner不生成txt测试报告
- Eggjs -typeorm treeenity practice
- selenium备忘录:selenium\webdriver\remote\remote_connection.py:374: ResourceWarning: unclosed<xxxx>解决办法
- 由於不正常斷電導致的unexpected inconsistency;RUN fsck MANUALLY問題已解决
- Kotlin - verify whether the time format is yyyy MM DD hh:mm:ss
- NodeJs - Express 中间件修改 Header: TypeError [ERR_INVALID_CHAR]: Invalid character in header content
- pytest(3)parametrize参数化
猜你喜欢

Sentinel Alibaba open source traffic protection component

Sentinel rules persist to Nacos

qq邮箱接收不到jenkins构建后使用email extension 发送的邮件(timestamp 或 auth.......)

Latex在VSCODE中编译中文,使用中文路径问题解决

Blog directory of zzq -- updated on 20210601

pytest(2) mark功能

Shardingsphere JDBC

Summary of advertisement business bug replay

web自动中利用win32上传附件

Name six schemes to realize delayed messages at one go
随机推荐
Solution to the black screen of win computer screenshot
Self cultivation of programmers - Reflection on job hunting
Unexpected inconsistency caused by abnormal power failure; Run fsck manually problem resolved
Latex参考文献引用失败 报错 LaTeX Warning: Citation “*****” on page y undefined on input line *
unittest. Texttestrunner does not generate TXT test reports
看完有用的blog
Latest CUDA environment configuration (win10 + CUDA 11.6 + vs2019)
Error "list" object is not callable in Web automatic switching window
eslint配置代码自动格式化
Sublime text configuring PHP compilation environment
The intern left a big hole when he ran away and made two online problems, which made me miserable
Sparse array (nonlinear structure)
Improve user experience defensive programming
构建学习tensorflow
Huawei mindspire open source internship machine test questions
Blog directory of zzq -- updated on 20210601
QQ email cannot receive the email sent by Jenkins using email extension after construction (timestamp or auth...)
Android - Kotlin 下使用 Room 遇到 There are multiple good constructors and Room will ... 问题
Sentinel rules persist to Nacos
Présence d'une panne de courant anormale; Problème de gestion de la fsck d'exécution résolu