Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: Thomas 'PointedEars' Lahn Newsgroups: comp.lang.javascript Subject: Re: Differences between [[Class]] and constructor Date: Tue, 02 Jun 2015 22:58:02 +0200 Organization: PointedEars Software (PES) Lines: 32 Message-ID: <6733032.WIyCHQfpTH@PointedEars.de> References: Reply-To: Thomas 'PointedEars' Lahn Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8Bit X-Trace: solani.org 1433278847 29629 eJwNycEBwCAMAsCVqhLEcWoM+4+g37sYbMwJBhEOn169a03xiXlKr4rAchL+MDKlv5o3NlUXDakQ+w== (2 Jun 2015 21:00:47 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Tue, 2 Jun 2015 21:00:47 +0000 (UTC) User-Agent: KNode/4.14.2 X-User-ID: eJwFwQkBACAIA8BKiGNgHOXpH8E721xMB42wsXmZepQqaDXXK73sASJp9HPCp5DyelW1xHCXOgvj+0Z25Ac94hVl Cancel-Lock: sha1:qa8KUIVTbmrtma+ElH8orhg4/Fc= X-NNTP-Posting-Host: eJwFwQEBwDAIAzBNh7YcOYOBfwlL6PrUAVHgci9WGEuDNquQTWKncQZR/2kp/JaLuWPMBySVEVM= Xref: csiph.com comp.lang.javascript:27967 Stefan Ram wrote: > I have observed that the class ([[Class]]) name That is _not_ the “class name”, it is the value of the internal “[[Class]]” property of values. “[[Class]]” is purely a Specification mechanism and does not need to be implemented in a way other than to satisfy the algorithms of the Specification. > and the constructor name of an object often is the same! Often, but not always. As specified. > 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] > let n = new Number( 3.14 ); var n = Math.PI; -- PointedEars FAQ: | SVN: Twitter: @PointedEars2 | ES Matrix: Please do not cc me. / Bitte keine Kopien per E-Mail.