Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #30180
| Path | csiph.com!weretis.net!feeder4.news.weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Newsgroups | comp.lang.javascript |
| Subject | Re: convert a string into a json object, |
| Supersedes | <15050773.1goHtK1mDU@PointedEars.de> |
| Date | Sat, 02 Apr 2016 03:48:23 +0200 |
| Organization | PointedEars Software (PES) |
| Lines | 62 |
| Message-ID | <3785004.pgkuUax1YM@PointedEars.de> (permalink) |
| References | <c8134afb-b7f5-4e2d-b3e6-90f8a3594544@googlegroups.com> <json-20160401033220@ram.dialup.fu-berlin.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| Content-Transfer-Encoding | 8Bit |
| X-Trace | solani.org 1459561704 22347 eJwFwYEBwCAIA7CXrNDCzpkC/59gQhN0w0U5h9O5kF2+1SxYnnWBJNw4peL+4zgS52MHTA8MgBA+ (2 Apr 2016 01:48:24 GMT) |
| X-Complaints-To | abuse@news.solani.org |
| NNTP-Posting-Date | Sat, 2 Apr 2016 01:48:24 +0000 (UTC) |
| User-Agent | KNode/4.14.2 |
| Cancel-Key | sha1:hVya7+Pn06Y5AyeRcy0ZeAzNbWo= |
| X-User-ID | eJwFwQkBwDAIA0BLDU9a5AAD/xJ250qwr9Fpvr5NY7UIxjVgiH6BizlRYykspgFp9eK0fnbdd1GejzpC+QEzNxSb |
| Cancel-Lock | sha1:9Jzdr9qlPawYLC0weOCtgzQEl80= |
| X-NNTP-Posting-Host | eJwNxsERACEIBLCWhIU9KAcO7b8EnXzioPD/jE7z82RkUCBWNETErhzF2mdNEJB+71SfhLXWBfiqEBw= |
| Xref | csiph.com comp.lang.javascript:30180 |
Show key headers only | View raw
Stefan Ram wrote:
> JRough <janis.rough@gmail.com> writes:
>>var
>>string='Janis_SF_WebDev"\n"Debby_SJ_WebDev"\n"Stephanie_Fl_Recruite"\n"';
>
> main = function self()
Unwise.
1. Undeclared identifier: main. Breaks in strict mode.
2. Used/confusing/unnecessary name: self.
- Used/confusing:
* There is window.self;
* the name breaks local code with unqualified references to
“self” written under the assumption that it refers to
the same object as “window.self”.
- Unnecessary: In your code, “self” is not even used. There is no
recursion, no self() call.
* Older environments create a global “self” variable.
> { "use strict";
> const result = {};
^^^^^
> const string =
> 'Janis_SF_WebDev"\n"Debby_SJ_WebDev"\n"Stephanie_Fl_Recruite"\n"'; const
> row = string.split( '"\n"' ); for( let i = 0; i < 3; ++i )
^^^
> { const record = row[ i ].split( "_" );
> const person = {};
Unnecessary incompatibility.
> person.name = record[ 0 ];
If the value is at least conceptionally *constant*, how come it is
*modified* to contain a new property?
If the identifier is conceptionally *a* *constant*, how come it is assigned
a reference to a *new* object on each iteration?
> […]
> person.city = record[ 1 ];
> person.job = record[ 2 ];
> result[ i ]= person; }
>
> console.log( JSON.stringify( result ));
> return result; };
>
> main();
As usual, your code, including your code style, is, unnecessarily,
a maintenance nightmare.
Ever heard of the module pattern and other environments than the latest
Firefox?
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
convert a string into a json object, JRough <janis.rough@gmail.com> - 2016-03-31 19:12 -0700
Re: convert a string into a json object, Stefan Weiss <krewecherl@gmail.com> - 2016-04-01 10:42 +0200
Re: convert a string into a json object, JRough <janis.rough@gmail.com> - 2016-04-01 17:32 -0700
Re: convert a string into a json object, Stefan Weiss <krewecherl@gmail.com> - 2016-04-01 10:49 +0200
Re: convert a string into a json object, John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-01 19:21 +0100
Re: convert a string into a json object, Aleksandro <aleksandro@gmx.com> - 2016-04-01 16:21 -0300
Re: convert a string into a json object, Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-04-01 20:36 +0100
Re: convert a string into a json object, Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-02 04:07 +0200
Re: convert a string into a json object, Aleksandro <aleksandro@gmx.com> - 2016-04-02 12:07 -0300
Re: convert a string into a json object, Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-02 17:36 +0200
Re: convert a string into a json object, Aleksandro <aleksandro@gmx.com> - 2016-04-02 21:01 -0300
Re: convert a string into a json object, Scott Sauyet <scott@sauyet.com> - 2016-04-02 20:40 +0000
Re: convert a string into a json object, Stefan Weiss <krewecherl@gmail.com> - 2016-04-02 01:18 +0200
Re: convert a string into a json object, John Harris <niam@jghnorth.org.uk.invalid> - 2016-04-02 11:29 +0100
Re: convert a string into a json object, Scott Sauyet <scott@sauyet.com> - 2016-04-02 20:30 +0000
Re: convert a string into a json object, JRough <janis.rough@gmail.com> - 2016-04-01 11:32 -0700
Re: convert a string into a json object, Stefan Weiss <krewecherl@gmail.com> - 2016-04-02 00:51 +0200
Re: convert a string into a json object, Aleksandro <aleksandro@gmx.com> - 2016-04-02 12:03 -0300
Re: convert a string into a json object, Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-02 03:48 +0200
Re: convert a string into a json object, Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-02 04:25 +0200
csiph-web