Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27963
| From | Andreas Bergmaier <andber93@web.de> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Differences between [[Class]] and constructor |
| Date | 2015-06-02 21:32 +0200 |
| Organization | albasani.net |
| Message-ID | <mkl0d3$c6d$1@news.albasani.net> (permalink) |
| References | <ct69cmFtvojU1@mid.uni-berlin.de> |
Stefan Ram schrieb:
> I have observed that the class ([[Class]]) name and the
> constructor name of an object often is the same!
This might be the case for plain objects with the native constructors.
It is not for almost every other object, like
var p = new (function Person(){});
className(p) // "object"
p.constructor // Person
> The first difference I found is: You can change the
> constructor name, but not the class name.
Not exactly. You cannot change constructor names either, as the `.name`
property of functions is typically non-writable (if it exists at all, it
is non-standard, as opposed to [[Class]]). See
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
for more information.
What you can arbitrarily change is the `.constructor` property of any
normal object, there are no limitiations here.
Bergi
Back to comp.lang.javascript | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Differences between [[Class]] and constructor Andreas Bergmaier <andber93@web.de> - 2015-06-02 21:32 +0200 Re: Differences between [[Class]] and constructor Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-06-02 23:05 +0200
csiph-web