Home  >  Article  >  Web Front-end  >  How to determine if the page object is empty in JS

How to determine if the page object is empty in JS

小云云
小云云Original
2018-03-15 16:05:232271browse

This article mainly shares with you how JS determines that the page object is empty. We have shared three methods with you, hoping to help you.
The first type:

function isEmptyObject(e) 
{
    var t;   
     for (t in e)       
      return !1;   
       return !0}

The second type:

function isEmptyObject(e) 
{
    if(Object.keys(e).length === 0)       
         return true;            
          return false;}

The third type:

function isEmptyObject(e) 
{
     if(Object.getOwnPropertyNames(object).length ===0)
         return true; 
     return false;}

Related recommendations:

JS/Jquery method to determine if an object is empty_javascript skills

The above is the detailed content of How to determine if the page object is empty in 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