Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an if statement in javascript that will run if a variable is undefined? [duplicate]

Possible Duplicate:
Detecting an undefined object property in JavaScript

Would it be like this?

if(variable == undefined) {

or would it be like this?

if(variable == "undefined") {
like image 898
chromedude Avatar asked Dec 13 '25 04:12

chromedude


1 Answers

if (typeof variable == 'undefined')

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!