DEV Community

loading...

Discussion on: 💡 How to check if a variable is undefined in JS

Collapse
estevanjantsk profile image
Estevan Jantsk

I'm wondering why would you add a variable inside an if if you didn't at least declared or received that variable as a parameter.

Collapse
benjaminmock profile image
Benjamin Mock Author

It might be because you don't know if a variable is declared or not. e.g. You have a global window object in the browser, but not in Node.js