News for hackers. Stuff that matters.
Re:Prototypes Are Not Classes by lispm on Sunday January 19, 2014 @02:32PM (#7085603)
Jesus, the language is called Smalltalk. Not SmallTalk.

Btw., in a typical language supporting prototypes, I would expect that prototypes are nothing special. Every object could be a prototype for others...

Re:Prototypes Are Not Classes by klibertp on Sunday January 19, 2014 @03:18PM (#7085807)
That's true in JavaScript - there's an Object.create() method, which creates new object with any other object set as prototype: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

There is a problem with accessing prototypes of objects, as they are not exposed to the user and only available through internal property __prototype__ (IIRC). And there's quite a bit of magic involved with constructor prototypes, which - again - makes it impossible to traverse prototype chain unless you create your objects yourself and store the references yourself.

So yeah, prototypes are nothing special in JS, but their API kind of sucks and could get better. Object.create is a step in the right direction IMO.

Re:Prototypes Are Not Classes by masklinn on Sunday January 19, 2014 @03:40PM (#7085900)
> There is a problem with accessing prototypes of objects, as they are not exposed to the user

Actually, Object.getPrototypeOf was added in ECMAScript 5.1. It's even supported by IE9.

> only available through internal property __prototype__ (IIRC)

It's an external property (the internal one is `[[Prototype]]`_, and is called `__proto__`. It's non-standard, although all modern browsers implement it (even IE11, but not IE10)

Re:Prototypes Are Not Classes by klibertp on Monday January 20, 2014 @04:46AM (#7088555)
> the internal one is `[[Prototype]]`

I was thinking about this one.

> Actually, Object.getPrototypeOf was added in ECMAScript 5.1.

Wow. Thanks, I wasn't aware of this.

Re:Prototypes Are Not Classes by raganwald on Sunday January 19, 2014 @03:59PM (#7085968)
And weirdly, I often miss-spell JavaScript as "Javascript." No idea why.