Home  >  Article  >  Web Front-end  >  How to determine if an array is empty in jquery?

How to determine if an array is empty in jquery?

青灯夜游
青灯夜游Original
2020-11-20 14:57:046104browse

Jquery method to determine whether an array is empty: first use the length attribute to get the number of elements in the array object, and then determine whether the number of elements obtained is equal to 0. If it is equal to 0, the array is empty, otherwise it is not empty. ;Syntax "if (array object.length === 0) {//array is empty}".

How to determine if an array is empty in jquery?

Related recommendations: "jQuery Video"

jquery method to determine whether an array is empty

var arr = [ "xml", "html", "css", "js" ]; 
if(arr.length == 0){
  console.log("数组为空");
}else{
	console.log("数组不为空");
}

Output

How to determine if an array is empty in jquery?

jQuery length property

The length property contains the number of elements in the jQuery object

For more programming-related knowledge, please visit: Programming Learning Website! !

The above is the detailed content of How to determine if an array is empty in jquery?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:What can jquery doNext article:What can jquery do