[flexcoders] Checking if an object exists
Hello all, I'm here for one of my questions again :P I need to make a comparison like this if (archive[record_id][1].deleted_id == deleted_id) { } My problem is that [1].deleted_id might not exist at this point. I know that archive[record_id] exists so how can i make this comparison above? [1] might not exists and i can't use hasOwnProperty(1) because it throws an error as well. can someone help me?! :P raf
Re: [flexcoders] Checking if an object exists
If it's an array, then you want: if(archive[record_id].length 1) { //do stuff } -Josh On Tue, Jul 29, 2008 at 2:05 PM, Rafael Faria [EMAIL PROTECTED]wrote: Hello all, I'm here for one of my questions again :P I need to make a comparison like this if (archive[record_id][1].deleted_id == deleted_id) { } My problem is that [1].deleted_id might not exist at this point. I know that archive[record_id] exists so how can i make this comparison above? [1] might not exists and i can't use hasOwnProperty(1) because it throws an error as well. can someone help me?! :P raf -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]
Re: [flexcoders] Checking if an object exists
Also, you can check: if (1 in archive[record_id]) { //do stuff } -Josh On Tue, Jul 29, 2008 at 2:32 PM, Josh McDonald [EMAIL PROTECTED] wrote: If it's an array, then you want: if(archive[record_id].length 1) { //do stuff } -Josh On Tue, Jul 29, 2008 at 2:05 PM, Rafael Faria [EMAIL PROTECTED] wrote: Hello all, I'm here for one of my questions again :P I need to make a comparison like this if (archive[record_id][1].deleted_id == deleted_id) { } My problem is that [1].deleted_id might not exist at this point. I know that archive[record_id] exists so how can i make this comparison above? [1] might not exists and i can't use hasOwnProperty(1) because it throws an error as well. can someone help me?! :P raf -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED] -- Therefore, send not to know For whom the bell tolls. It tolls for thee. :: Josh 'G-Funk' McDonald :: 0437 221 380 :: [EMAIL PROTECTED]