Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27975
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Style: new String( "abc" ) |
| Date | 2015-06-03 10:15 +0200 |
| Organization | Liberty Development |
| Message-ID | <mkmd34$25oc$1@adenine.netfront.net> (permalink) |
| References | <new-style-20150602185946@ram.dialup.fu-berlin.de> |
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
Re: Style: new String( "abc" ) Martin Honnen <mahotrash@yahoo.de> - 2015-06-03 10:15 +0200
csiph-web