Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30930
| Newsgroups | comp.lang.javascript |
|---|---|
| Subject | Re: Any way to do this in JavaScript? |
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
| References | <nmln2h$kbr$1@dont-email.me> <aee721b8-10bc-4946-8d04-85b786e13bec@googlegroups.com> |
| Date | 2016-07-20 10:56 +0200 |
| Message-ID | <XnsA64B6F5693ACAeejj99@194.109.6.166> (permalink) |
"Michael Haufe (TNO)" <tno@thenewobjective.com> wrote on 20 Jul 2016 in
comp.lang.javascript:
> var [a, b, c] = "1,2,3".split(",");
Nice!
==================
No equal array-lengths necessary [Chrome tested]:
var weekdaysplus =
"Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday,";
var warray = weekdaysplus.split(/,/)
var [mo,tu,we,th,fr,sa,su,xx,yy] = warray;
document.write([fr,mo,su].join(' =1= '));
document.write('<br>' + typeof xx);
document.write('<br>' + typeof yy);
var [a,b,c] = warray;
document.write('<br>' + [a,b].join(' =2= '));
var [,,a,b,c] = warray;
document.write('<br>' + [a,b,c].join(' =3= '));
gives:
Friday =1= Monday =1= Sunday
string
undefined
Monday =2= Tuesday
Wednesday =3= Thursday =3= Friday
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Any way to do this in JavaScript? $Bill <news@todbe.com> - 2016-07-19 10:12 -0700
Re: Any way to do this in JavaScript? Martin Honnen <martin.honnen@gmx.de> - 2016-07-19 20:14 +0200
Re: Any way to do this in JavaScript? $Bill <news@todbe.com> - 2016-07-19 12:02 -0700
Re: Any way to do this in JavaScript? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-19 21:05 +0200
Re: Any way to do this in JavaScript? $Bill <news@todbe.com> - 2016-07-19 12:49 -0700
Splitting strings (was: Any way to do this in JavaScript?) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-07-20 00:25 +0200
Re: Splitting strings (was: Any way to do this in JavaScript?) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-20 09:45 +0200
Re: Any way to do this in JavaScript? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-07-19 23:21 -0700
Re: Any way to do this in JavaScript? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-20 10:56 +0200
csiph-web