How does js determine that undefined null is empty at the same time?

  1. now I judge whether a variable is valid by the following way (that is, undefined null " each judge once):
if( (this.$route.query.openid != undefined || this.$route.query.openid != null || this.$route.query.openid != "" ) && window.localStorage.getItem("openid") != "")
{
      ......
 }

I would like to ask JS or Vue or ES is there any way to directly determine whether a variable is valid at once?

Mar.21,2021

the answer of @ original sin adopted by the landlord is not accurate enough. With a rigorous and responsible attitude, it is necessary to add that when making a judgment first, if a variable is not declared, it cannot be judged directly. For example, the following judgment will report an error.

const nullReg = /^(undefined|null|)$/;
if(!nullReg.test(this.$route.query.openid) && !nullReg.test(window.localStorage.getItem('openid'))) {
  ...
}
Menu