Home > Web Front-end > JS Tutorial > body text

How to determine if an array is empty in jquery?

青灯夜游
Release: 2020-11-20 14:57:04
Original
5892 people have browsed it

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("数组不为空");
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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 [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!