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


Groups > comp.lang.javascript > #27962

Re: Style: new String( "abc" )

From Andreas Bergmaier <andber93@web.de>
Newsgroups comp.lang.javascript
Subject Re: Style: new String( "abc" )
Date 2015-06-02 21:25 +0200
Organization albasani.net
Message-ID <mkl000$bif$1@news.albasani.net> (permalink)
References <new-style-20150602185946@ram.dialup.fu-berlin.de>

Show all headers | View raw


Stefan Ram schrieb:

>  the primitve "abc" was implicitly converted
>  into an object /three times/.

In the old times, maybe. Current compilers don't convert anything to an 
object any more here, they just call the native 
`String.prototype.charAt` method directly on the primitive value.

> Wouldn't this be more
> efficient? So, why could it be bad style?

Even efficient code can be bad style :-) (think about goto for an 
extreme example).
The wrapper creation is just unnecessary and overly verbose. With very 
little gain.

  Bergi

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


Thread

Re: Style: new String( "abc" ) Andreas Bergmaier <andber93@web.de> - 2015-06-02 21:25 +0200
  Re: Style: new String( "abc" ) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-02 22:27 +0200
    Re: Style: new String( "abc" ) Andreas Bergmaier <andber93@web.de> - 2015-06-02 23:51 +0200
      Re: Style: new String( "abc" ) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-03 01:17 +0200
        Re: Style: new String( "abc" ) Andreas Bergmaier <andber93@web.de> - 2015-06-03 06:22 +0200
          Re: Style: new String( "abc" ) Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-03 07:57 +0200
            Re: Style: new String( "abc" ) Andreas Bergmaier <andber93@web.de> - 2015-06-03 18:36 +0200
          Re: Style: new String( "abc" ) John Harris <niam@jghnorth.org.uk.invalid> - 2015-06-03 15:38 +0100

csiph-web