Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30916
| From | $Bill <news@todbe.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Any way to do this in JavaScript? |
| Date | 2016-07-19 12:49 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <nmm07r$mmi$1@dont-email.me> (permalink) |
| References | <nmln2h$kbr$1@dont-email.me> <1889594.irdbgypaU6@PointedEars.de> |
On 7/19/2016 12:05, Thomas 'PointedEars' Lahn wrote:
>
> Conforming implementations of ECMAScript 2015 support the destructuring
> assignment, formerly introduced for arrays only with Mozilla JavaScript 1.7:
>
> var [title, chan, call, sTime, dur] = el.split('~~');
>
> <http://PointedEars.de/scripts/test/es-matrix/?filter=%5D%5Cs%2B%3D%20Array>
> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment> pp.
>
>
> If one of the implementations that you need to support does not have that
> feature, you can use something like my jsx.array.destructure() [1]:
>
> var obj = jsx.array.destructure(el.split('~~'),
> ["title", "chan", "call", "sTime", "dur"]);
>
> Afterwards there are enumerable, writable, and configurable properties,
> respectively:
>
> obj.title
> obj.chan
> obj.call
> obj.sTime
> obj.dur
Thanks for your further clarification of the issue.
> Note that while in Perl your delimiter is always considered a regular
> expression (see perlfunc(1)), in ECMAScript implementations it can be either
> a string value or a regular expression. In this case, using a string value
> as you did is the proper, most efficient, approach.
If you're referring to the split delimiter/pattern, it can be an RE or a string in Perl.
> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split>
>
>
> Next time, post with your real name. This is Usenet, not a chat room.
It's a nickname. I used it for 21 years at JPL/NASA and it was good enough for them ...
I earned it at Litton - Data Systems Division - it actually is supposed to be a 1 and S
superimposed and I used it to initial in tiny boxes back in my operation days and I
attached it to my first name for brevity in submitting jobs later on. I plan on using
it till I succumb to the environment and leave this plane - if that's all the same to you. ;)
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next 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