javascript check if not undefined

To check if a variable is not undefined in Node.js using JavaScript, you can use the following code:

if (typeof variable !== 'undefined') {
  // Variable is not undefined
  console.log('Variable is not undefined');
} else {
  // Variable is undefined
  console.log('Variable is undefined');
}