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


Groups > comp.lang.javascript > #27967

Re: Differences between [[Class]] and constructor

From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Differences between [[Class]] and constructor
Date 2015-06-02 22:58 +0200
Organization PointedEars Software (PES)
Message-ID <6733032.WIyCHQfpTH@PointedEars.de> (permalink)
References <ct69cmFtvojU1@mid.uni-berlin.de>

Show all headers | View raw


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: <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 — Next in thread | Find similar | Unroll thread


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