Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27969
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Differences between [[Class]] and constructor |
| Date | 2015-06-02 23:07 +0200 |
| Organization | PointedEars Software (PES) |
| Message-ID | <1528792.TAupHRCX4z@PointedEars.de> (permalink) |
| References | <ct69cmFtvojU1@mid.uni-berlin.de> <6733032.WIyCHQfpTH@PointedEars.de> |
Thomas 'PointedEars' Lahn wrote:
> Stefan Ram wrote:
>> function className( object )
>> { return 0,
>> Object.prototype.toString.call( object ).
>> replace( "\[object ", "" ).replace( "\]", "" ); }
>
> This is written shorter, less error-prone, more efficient, and actually
> readable
>
> (({}).toString.call(object).match(/\[object\s+(.+)\s*\]/) || [])[0]
[1], of course. (So much for “less error-prone” ;-))
--
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.
Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread
Re: Differences between [[Class]] and constructor Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-02 22:58 +0200 Re: Differences between [[Class]] and constructor Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-02 23:07 +0200
csiph-web