Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27970
| From | Andreas Bergmaier <andber93@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Style: new String( "abc" ) |
| Date | 2015-06-02 23:51 +0200 |
| Organization | albasani.net |
| Message-ID | <mkl8h8$17b$1@news.albasani.net> (permalink) |
| References | <new-style-20150602185946@ram.dialup.fu-berlin.de> <mkl000$bif$1@news.albasani.net> <2130550.8QLrkFYiEJ@PointedEars.de> |
Thomas 'PointedEars' Lahn schrieb: > Andreas Bergmaier wrote: > >> 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. > > Cite evidence. This should get you started: http://stackoverflow.com/questions/17256182/what-is-the-difference-between-string-literals-and-string-objects-in-javascript The speed tests (http://jsperf.com/heera-string-literal-vs-object) linked from there speak for themselves. You can read yourself through the V8 code, they do distinguish between primitive values and objects a lot to gain extra optimisations. I couldn't locate the exact code myself, but when you have to look up a property on a primitive value you can directly jump to the respective prototype intrinsic object. There's no need to create a wrapper object, unless the lookup turns out to become a method call of a sloppy-mode function. I also found this bug report:http://code.google.com/p/v8/issues/detail?id=1212 which seems to have been forgotten in 2011. Bergi
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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