js-if判断非空等情况

const emptyValue ='';
          const undefinedValue = undefined;
          const nullValue = null;
          const emtpyArrayValue = [];
          const emptyObjectValue = {};
          const secondLevelObjectValue ={name:'name'};
          if(emptyValue ||
            undefinedValue ||
            nullValue ||
            emtpyArrayValue.length>0 ||
            Object.keys(emptyObjectValue).length>0 ||
            secondLevelObjectValue.title
            ){
           console.log(‘空’);
          }else{
            console.log(‘非空’);
          }

  

posted on 2024-07-26 18:10  技术高超  阅读(9)  评论(0编辑  收藏  举报