Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.javascript Subject: Re: Create array using name from string? Date: Tue, 28 May 2019 17:06:21 +0100 Organization: A noiseless patient Spider Lines: 19 Message-ID: <87h89elg1u.fsf@bsb.me.uk> References: <38042cf3-73ca-403a-b13b-7bcfbec21ffb@googlegroups.com> <84fe9111-5bab-4537-8d08-424ec56763d7@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: reader02.eternal-september.org; posting-host="b13d26f515683f72e6c75d8b83f24bd5"; logging-data="19481"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+VCVokfOKxfBK2qUe7Gm15ftRpM6nhmBY=" Cancel-Lock: sha1:W28Owt0Rb+Ud6KaKd2W5pdK2EFw= sha1:MlqKhaSexQcmZLJV21wNR6k67HQ= X-BSB-Auth: 1.77c0ef958d6e8a35fde2.20190528170621BST.87h89elg1u.fsf@bsb.me.uk Xref: csiph.com comp.lang.javascript:36658 dr.j.r.stockton@gmail.com writes: > On Tuesday, 28 May 2019 11:03:03 UTC+1, R.Wieser wrote: > >> Forget what I said. I just noticed that this is the javascript newsgroup, >> and not the VBScript one. My bad. > > No matter - your reply only needed translation :- > > S = "Banana" > eval("var " + S + " = [2, 9, +new Date()]") > Banana // is now a three-element array Mind you, it's worth pointing out, I think, that this sort of code is widely regarded as a Very Bad Thing. The OP is immune to such suggestions but there may be innocent learners reading this! -- Ben.