4 ms·
Actually, the evolution of the language has been adding "class-like" features over time. It was most definitely not designed originally to mimic classes. That's
by _getify 13y ago
Actually, the evolution of the language has been adding "class-like" features over time. It was most definitely not designed originally to mimic classes. That's been the demand of all the classicists coming to the language. There are those of us who wish for the language to not have all those things.
In parts 2 and 3, I'll make the case for why I think all those things don't belong in JS and should be removed or avoided.
- jarek-foksa 13y agoThere was really little evolution of the language since 1995. It was initially launched as a "perfect complement to Java" [1] and until recently its development was stalled. Constructors and "new" were there from the beginning. Nobody have even noticed the prototypal nature of JS until people like Crockford started evangelising it 10 years later, which in turn resulted in the addition of Object.create() in ES5. [1] http://www2.ldc.lu.se/temadag95/javascript.txt http://www2.ldc.lu.se/temadag95/javascript.txt
- _getify 13y agoI'm not sure the actual history bears out your assertion that 1995 was the fix-point date for all/most of these concepts. AIUI, functions were not originally first-class citizens. My understanding is (and I may very well be incorrect), in these very early days, functions not being objects precluded an awful lot of what we currently "know" to be true about how JS emulates "classes" with function.prototype. I tried to find good citations for this fact, but I'm having trouble finding good "early JavaScript" history. I do know that at least as early as ES1, in mid-1997, we had constructors with prototypes and "new". [1] In any case, besides `Object.create()` which you've noted, here are some other milestones in the evolution of "OO in JS" I could find: `instanceof` was added in JavaScript 1.4 [2], which was sometime after Oct 1998 [3], probably officially in ES3. `Object#isPrototypeOf()` was added in ES3 [4], which was around late 1999. `Object.getPrototypeOf()` was added in ES5 [5], which was around 2009. [1] http://www.ecma-international.org/publications/files/ECMA-ST-ARCH/ECMA-262,%201st%20edition,%20June%201997.pdf http://www.ecma-international.org/publications/files/ECMA-ST... [2] https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/instanceof https://developer.mozilla.org/en-US/docs/JavaScript/Referenc... [3] http://en.wikipedia.org/wiki/Javascript#Version_history http://en.wikipedia.org/wiki/Javascript#Version_history [4] https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/isPrototypeOf https://developer.mozilla.org/en-US/docs/JavaScript/Referenc... [5] https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/getPrototypeOf https://developer.mozilla.org/en-US/docs/JavaScript/Referenc...