Earlier quoted context omitted.
So, if initially there were no Array nor Object constructors (there were arrays and objects, but only prepopulated ones, representing anchors, forms, etc, found in the document), how were arrays done in a script? function MyArray() { this.length = 0; } function arrayPush( value ) { return this[this.length++] = value; } function arrayPop() { return this[--this.length]; } MyArray.prototype.push = arrayPush; MyArray.pro…
There was no `prototype` and `constructor` properties o = new Object o.foo = 'bar' a = new Array a[0] = 'baz' But functions were constructors function hello() { return this.name } function Person(name) { this.name = name this.hello = hello } new Person('James') Array push var length = 0 a[length++] = 'foo' a[length++] = 'bar' Actually it was not bad for scripting language , no WAT: new Object + new Array //null is no…
You are correct. The prototype property was yet another JavaSript1.1 (NS3) feature. (Totally forgot about that.) So, ignore '.prototype' in my example. But you could assign properties and methods to objects. Therefor it was more like,
var a = new MyArray();
a.pop = arrayPop();
a.push = arrayPush();
> No `typeof` (so no `typeof null`), better `parseInt`Fun fact: also no `isNAN()`. This was, once again, introduced with JS1.1/NS3 and still nonfunctional in IE3 – yes, IE3 had a few of those nonfunctional implementations.
(`isNAN()` was actually available in the Unix implementation of Netscape 2, but this was of lesser concern for the public Web.)
On the positive side, the access to forms and the various form elements was pretty sound and mature, right from the beginning, since this was what JS was pretty much all about.