Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27975

Re: Style: new String( "abc" )

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!goblin3!goblin.stu.neva.ru!news.netfront.net!not-for-mail
From Martin Honnen <mahotrash@yahoo.de>
Newsgroups comp.lang.javascript
Subject Re: Style: new String( "abc" )
Date Wed, 03 Jun 2015 10:15:30 +0200
Organization Liberty Development
Lines 21
Message-ID <mkmd34$25oc$1@adenine.netfront.net> (permalink)
References <new-style-20150602185946@ram.dialup.fu-berlin.de>
Reply-To Martin.Honnen@gmx.de
NNTP-Posting-Host 89.244.252.165
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 8bit
X-Trace adenine.netfront.net 1433319332 71436 89.244.252.165 (3 Jun 2015 08:15:32 GMT)
X-Complaints-To news@netfront.net
NNTP-Posting-Date Wed, 3 Jun 2015 08:15:32 +0000 (UTC)
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1
In-Reply-To <new-style-20150602185946@ram.dialup.fu-berlin.de>
Xref csiph.com comp.lang.javascript:27975

Show key headers only | View raw


ram@zedat.fu-berlin.de (Stefan Ram) wrote:
>    IIRC, I read somewhere that one should prefer to use
>    primitives such as "abc"; one should not create objects
>    via »new String ( "abc )« (or, »new Number( 7 )«).
>
>    I am not sure why »new String( "abc" )« should be bad style.


Well with

   var s1 = new String("foo"); var s2 = new String("foo"); s1 == s2

you get "false" while with

   var s1 = "foo"; var s2 = "foo"; s1 == s2

you get "true" so it is not necessarily a question of style but of 
semantics you would want to have when using your data in expressions.


--- news://freenews.netfront.net/ - complaints: news@netfront.net ---

Back to comp.lang.javascript | Previous | Next | Find similar | Unroll thread


Thread

Re: Style: new String( "abc" ) Martin Honnen <mahotrash@yahoo.de> - 2015-06-03 10:15 +0200

csiph-web