Path: csiph.com!aioe.org!.POSTED!not-for-mail From: Dr J R Stockton Newsgroups: comp.lang.javascript Subject: Re: Empty array Date: Thu, 1 Mar 2012 21:20:25 +0000 Organization: Home Lines: 31 Message-ID: References: <0f481e7c-97b9-4c76-9660-321681876658@w9g2000vbv.googlegroups.com> NNTP-Posting-Host: JfH6RRPWQh8XzArFI0xgxA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain;charset=us-ascii X-Complaints-To: abuse@aioe.org User-Agent: Turnpike/6.05-S () X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.javascript:12333 In comp.lang.javascript message , Tue, 28 Feb 2012 17:20:30, Gene Wirchenko posted: > > You could join the array and check against an empty string, but >that could be expensive with a large array. And expensive code is particularly bad value if it does not work. In current Firefox : A = [] A[4.67] = 66 A.length // 0 A.join() // blank A.join().length // 0 A[467/100] // 66 When testing for emptiness, the first thing to do is to define the sort of item that one wants to test for the absence of. My favourite tea-cup might be considered to be empty - it is upside- down. But it is almost full of air. It also contains about half a milk-bottle, itself empty - of milk but not of air. The air itself is almost empty; only about 0.1% of it is atoms. The atoms are even emptier. -- (c) John Stockton, nr London UK. ?@merlyn.demon.co.uk DOS 3.3 6.20 ; WinXP. Web - FAQqish topics, acronyms & links. PAS EXE TXT ZIP via My DOS - also batprogs.htm.