How to set a variable value if undefined in JavaScript

1 Answer

0 votes
let x = undefined;
let y;

x ??= 373;
console.log(x); 

y ??= 901;
console.log(y); 


 
 
     
     
/*
run:
      
373
901
      
*/

 



answered May 12, 2022 by avibootz

Related questions

...