Return to Snippet

Revision: 5871
at April 10, 2008 04:11 by zha


Initial Code
/* if (globalVariable) {

But this wouldn't work. That code is actually checking to see if the defined variable globalVariable has a null value. If the variable has not been defined, that code will cause an error.

Instead, here is the code that will check for the presence of a global variable:
*/
if (window.globalVariable) {

Initial URL
http://www.breakingpar.com/bkp/home.nsf/0/87256B14007C5C6A87256B260052B40B

Initial Description
/* if (globalVariable) {

But this wouldn't work. That code is actually checking to see if the defined variable globalVariable has a null value. If the variable has not been defined, that code will cause an error.

Instead, here is the code that will check for the presence of a global variable:
*/
if (window.globalVariable) {

Initial Title
Checking for global variable presence

Initial Tags
javascript

Initial Language
JavaScript