Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1753 How do you determine if a variable exists?

You are here: irt.org | FAQ | JavaScript | General | Q1753 [ previous next ]

Simply test if the window object has a property by the same name:

<script language="JavaScript"><!--
if (window.myVariableName) {
  alert('variable exists');
}
else {
  alert('either variable exits or its value is null or false');
}
//--></script>

Feedback on 'Q1753 How do you determine if a variable exists?'

©2018 Martin Webb