Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: End of selected items. Date: Tue, 12 Nov 2019 15:31:33 +0100 Lines: 32 Message-ID: References: <64be7dde-48ce-4a0a-8ae7-32ecbd9d1399@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net wCbJYjIyq5kIMARsWQhrfg620qobtpY5qVS8uOW0QPEom3XPB4 Cancel-Lock: sha1:ujGVaIoz8T0I+LaeGyXaL8CTP7s= In-Reply-To: <64be7dde-48ce-4a0a-8ae7-32ecbd9d1399@googlegroups.com> Content-Language: en-US Xref: csiph.com comp.lang.javascript:37762 On 11.11.19 11:52, Jonas Thörnvall wrote: > An array can hold elements with different types, there is no problem to step thru all elements of an array. > > But how do one handle stepping thru an array where you do not know the last element of a certain type? > > What is the condition for the increment->, that tells this was the last element? You step thru the whole array and just use the element if it is of a certain type and ignore the others. > You can't tell it was the last element until end of array? Should one just scroll thru and find last element index of each type and save at beginning? Yes. > I guess that must be done but am not sure, this problem must come up in every database? In a database one would just not query element types you don't want. For example with an SQL query: select * from articles where location='bookshelf' and NOT: "select * from articles" followed by a script which goes thru the result just to find the last article with the condition "location=='bookshelf'". -- Arno Welzel https://arnowelzel.de