Home  >  Article  >  Web Front-end  >  How to determine if an object is empty in vue.js

How to determine if an object is empty in vue.js

coldplay.xixi
coldplay.xixiOriginal
2020-11-10 11:11:2911119browse

vue.js method to determine if an object is empty: 1. Convert the object to JSON. If it is an empty collection [{}], then it is an empty object; 2. Determine the length of the object. If it is zero, then it is Empty object.

How to determine if an object is empty in vue.js

The operating environment of this tutorial: windows10 system, vue2.9, this article is applicable to all brands of computers.

【Recommended related articles: vue.js

vue.js method to determine if an object is empty:

Method 1: Convert the object to JSON. If it is an empty collection {}, then it is an empty object.

JSON.stringify(object)=='{}'

Method 2: Determine the length of the object. If it is zero, it is an empty object.

Object.keys(object).length==0

Related free learning recommendations: JavaScript (video)

The above is the detailed content of How to determine if an object is empty in vue.js. 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:How to get dom in vue.jsNext article:How to get dom in vue.js