How to determine if variable name is defined in JavaScript

1 Answer

0 votes
let y = 82;
if (typeof x !== 'undefined') {
    console.log("x=" + x);
}
if (typeof y !== 'undefined') {
    console.log("y=" + y);
}


   
/*
run:
       
y=82
 
*/

 



answered Jun 3, 2025 by avibootz

Related questions

2 answers 216 views
1 answer 164 views
2 answers 183 views
1 answer 194 views
1 answer 231 views
1 answer 142 views
...