How to judge whether an array is empty?
来源:互联网 发布:tomcat 多域名设置 编辑:程序博客网 时间:2024/04/30 20:03
Today I got an array from database.Before I used it,I first judged it.But I made a mistake,I used if(arr).I forgot an array is an object…
So if we want to judge whether an array is empty.take following measures:
var arr=[]; if(arr == "")//object will change to string and an empty array returns "" { //code goes here }
or
var arr=[];if(arr.length===0)//I recommend this for I do not want to use ==....
0 0
- How to judge whether an array is empty?
- How to judge if an iterator is used before.
- How to display an empty row when the underlying dataset is empty
- how to know whether an element has an class
- <boost -04>如何判断输入文件的类型在给定范围内?how to judge whether given file's extension is within list?
- how to know whether one string is english string
- How to Check Whether API Server is up or Down
- How to pass an empty string to Value Prompt
- Empty an Array
- How to remove Duplicates from an Array
- How to define an array in c#.
- How to initialize an array in C
- How To Remove An Empty ASM System Directory
- how to judge a string is eauql 0
- How to sensibly split an array around an object
- How to copy values of an array into another array
- How to find variable is empty in shell script
- how to fix GIT error: object file is empty?
- 滤镜高斯模糊的边界或边框问题的解决和优化
- left join on 和where条件的放置
- 人工智能之机器学习路线图
- leetcode——Two Sum II - Input array is sorted
- ssm框架返回json .do 406 (Not Acceptable)错误
- How to judge whether an array is empty?
- 165.Merge Two Sorted Lists-合并两个排序链表(容易题)
- 关于设置float的补充
- C#开发B/S方式ActiveX控件
- quartz2D 如何绘制圆形图片, 及圆环图片
- jbpm的学习(一)
- cuDNN:Efficient Primitives for Deep Learning 解读
- JAVA 实现文件(字符串)压缩与解压
- Weex入门与进阶指南