3 ms·
> Considering the original JS already contained the syntax Crockford would eventually define as JSON, you could say they managed to create not one but two langu
by Stratoscope 12y ago
> Considering the original JS already contained the syntax Crockford would eventually define as JSON, you could say they managed to create not one but two languages at once.
No, the original version of JavaScript did not include object literals and array literals - the two foundations of JSON.
Object and array literals were introduced in JavaScript 1.2:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_in_JavaScript/1.2 https://developer.mozilla.org/en-US/docs/Web/JavaScript/New_...
This is why old-school JavaScript programming had so much code like this:
var obj = new Object;
obj.prop = 'value';
and:
var ary = new Array;
ary[0] = 'first';
ary[1] = 'second';
- BrendanEich 12y agoRight, and note to grand-parent post: Crockford was not at Netscape so he's not the eyewitness you're looking for. I created JS1.2 and SpiderMonkey in fall 1996, as described in that JS Jabber podcast. Find this part in the transcript: "I started to rewrite the VM, pay off technical debt, and I wrote what became SpiderMonkey. The original Mocha VM was not SpiderMonkey." Object and array initialiser syntax was inspired by Python of the time (1996 would be Python 1.x, x around 6 IINM), but I made property names literals when spelled without quotes, as identifiers (same as the implicitly quoted name on the right of dot in member expressions). In ES6 (in imitation of computed property access using square brackets) you can finally compute property names in object initialisers too: var obj = { [nameExpr]: valueExpr };
- Telematica 12y agoAmazing. There is a bunch of stuff to ask for about JS API...
- pluma 12y agoOkay, so you didn't create the syntax JSON was based on until JS1.2? What I was getting at remains true then, though: you created JS and you created the object and array literal syntax that Crockford then "discovered" (to quote Crockford) and defined as JSON. Even if you didn't do it in the same couple of days it took you to create the original JS itself ;)