Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: General compute language, syntax question Date: Mon, 29 Feb 2016 15:11:27 +0000 Organization: A noiseless patient Spider Lines: 22 Message-ID: <87povflffk.fsf@bsb.me.uk> References: <615c2e25-d8b6-4803-a157-b7ba748d1c71@googlegroups.com> <93318b24-7815-4801-bea2-309e79c6f5dd@googlegroups.com> <1df59a2c-61fd-4431-885c-70f12d15f678@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="13245"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18uNag1zBC4UhS1H2+f2UUS0fSG53N9WT0=" Cancel-Lock: sha1:pKfkdoqnF9zilcmXC74v7eEy+xc= sha1:U+nossT6TmaakadMmRiEfPeELE8= X-BSB-Auth: 1.610f63625efae04c9a78.20160229151127GMT.87povflffk.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:29729 jonas.thornvall@gmail.com writes: > I mean how utterly fucking stupid must one be to come up with a > solution that require the programmer to check if the array[index] is > empty what index? Index for 0 it doesn't exist? Or do they require me > to loop thru an empty list how do you do that? It's possible that you are using the wrong data type for the job (an array is very different from a list, so if you need a list an array might be a bad fit). Anyway, if you are using the new ECMAScript you might find that !array.some(() => true) does what you want or even (depending on how you handle deleted elements) the much cheaper array.length == 0. For example, if you use push/pop/ shift/unshift to add and remove elements you'll find an empty "list" has length zero. -- Ben.