tag:blogger.com,1999:blog-542398624287876588.post5371970267670387058..comments2024-03-11T07:18:29.295+00:00Comments on Nifty Snippets: Myths and realities of for..inT.J. Crowderhttp://www.blogger.com/profile/05828354736681391962noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-542398624287876588.post-43931527956193111962013-07-17T09:59:59.569+01:002013-07-17T09:59:59.569+01:00@RobG: Thank you! Good point. `String(Number(index...@RobG: Thank you! Good point. `String(Number(index)) === index` is one of those "good enough" tests, but you're quite right it's wrong, and in a couple of different ways. (Consider properties with the names "2.5" or "00", for instance.) I've corrected it. Just to pick nits, your test has an OBOE in it (indexes can't be 2^32-1, so it would have to be &T.J. Crowderhttps://www.blogger.com/profile/03619792122821936638noreply@blogger.comtag:blogger.com,1999:blog-542398624287876588.post-12893985671565115172013-07-17T03:42:55.928+01:002013-07-17T03:42:55.928+01:00Good stuff, but the test String(Number(index)) ===...Good stuff, but the test <i>String(Number(index)) === index</i> seems inappropriate, testing the actual conditions required seems like a better idea: <i>/^0$|^[1-9]\d*$/</i>. Also, the largest index allowed is <i>2^32 - 1</i>, or 4294967295, so consider:<br /><br /><i>stuff.hasOwnProperty(index) && /^0$|^[1-9]\d*$/.test(index) && index < 4294967296</i>RobGhttps://www.blogger.com/profile/09168282831519876720noreply@blogger.comtag:blogger.com,1999:blog-542398624287876588.post-54578392309646590362011-08-26T04:48:00.021+01:002011-08-26T04:48:00.021+01:00@David: Gosh, thanks! I'm glad to have helped!...@David: Gosh, thanks! I'm glad to have helped!<br /><br />Best,<br /><br />-- T.J.T.J. Crowderhttps://www.blogger.com/profile/03619792122821936638noreply@blogger.comtag:blogger.com,1999:blog-542398624287876588.post-49255507726727810002011-08-26T04:37:26.707+01:002011-08-26T04:37:26.707+01:00I just wanna say THANK YOU! for all the knowledge ...I just wanna say THANK YOU! for all the knowledge you give away for free. I've read a few of your posts and you've already helped me become a much better developer. You're very smart and learned and you do neophyte coders like me a huge service with your blog. Thanks again.Davidhttps://www.blogger.com/profile/00178276131218967764noreply@blogger.com