You can actually just use (!var) in most cases. if (!undefined) { // This will always run. trace(undefined); } if (!null) { // This will always run. trace(null); } if (!false) { // This will always run. trace(false); } if (!0) { // This will always run. trace(0); } if (!"") { // This will always run. trace('""'); } if (!"".length) { // This will always run. trace('"".length'); } if (!"foo") { // This will always run. trace('"foo"'); } if (![].length) { // This will never run. trace("[].length"); } // Conversely... if (!"foo".length) { // This will always run. trace('"foo".length'); } if (!true) { // This will never run. trace(true); } if (!1) { // This will never run. trace(1); } if (!-1) { // This will never run. trace(-1); } if (!(Math.random() + 1)) { // This will never run. trace("Math.random() + 1"); } if (!{}) { // This will never run. trace("{}"); } if (![]) { // This will never run. trace("[]"); } -- T. Michael Keesey
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Rifled Cloaca Sent: Wednesday, July 19, 2006 8:00 AM To: Flashcoders mailing list Subject: [Flashcoders] Difference between null and undefined? FlashCoders, I've recently been upgrading some old Flash MX code to Flash 8, and have been running into issues where properties return 'undefined' instead of 'null'. I seem to recall that undefined was introduced in Flash 7. I've always been confused about when something is undefined versus null, so I always check for both. { (var != undefined && var != null) } Is there an explanation somewhere regarding the difference between undefined and null, and when to expect which? If not, can someone who understands explain it? Thanks in advance! -rc _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com