1

I am trying to check if a variable exists using a function but somehow this doesn't work, can somebody help me, thanks a lot!

// console returns false and is expected
if(typeof aaaaaaa !== 'undefined'){
  console.log(true);
}else{
  console.log(false);
}

=============================================

// console returns 'aaaaaaa is not defined', and stops my code
function checkExist(arg){
    if(typeof arg !== 'undefined'){
        console.log(true);
    }else{
        console.log(false);
    }
}
checkExist(aaaaaaa);

it's just different than JavaScript check if variable exists (is defined/initialized)

Community
  • 1
  • 1
Fu-Han Zhang
  • 75
  • 1
  • 1
  • 6

0 Answers0