Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27975 > unrolled thread
| Started by | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| First post | 2015-06-03 10:15 +0200 |
| Last post | 2015-06-03 10:15 +0200 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.javascript
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Style: new String( "abc" ) Martin Honnen <mahotrash@yahoo.de> - 2015-06-03 10:15 +0200
| From | Martin Honnen <mahotrash@yahoo.de> |
|---|---|
| Date | 2015-06-03 10:15 +0200 |
| Subject | Re: Style: new String( "abc" ) |
| Message-ID | <mkmd34$25oc$1@adenine.netfront.net> |
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 top | Article view | comp.lang.javascript
csiph-web