3 ms·
Color = Data(function() ({ Red: {}, Green: {}, Blue: {}, Yellow: {} })) Is this JS or pseudocode? There are some extra parens in there and the pattern repeats
by madflame991 11y ago
Color = Data(function() ({ Red: {}, Green: {}, Blue: {}, Yellow: {} }))
Is this JS or pseudocode? There are some extra parens in there and the pattern repeats everywhere.
- jessaustin 11y agoThat may be the "expression closure" from "javascript 1.8" that was mentioned. When was this written? 2008? I thought ES6 was the new hotness now? It just goes to show you, if you want future-proof, code in coffeescript. [EDIT:] ...which of course didn't exist until 2009. Anyway here it is: Color = Data -> Red: {}, Green: {}, Blue: {}, Yellow: {}
- tikhonj 11y agoThose are the JavaScript 1.8 (FF-only) "expression closures" the author mentions. JavaScript 1.8 introduces a succinct syntax for anonymous functions: function (a, b, c) a + b * c; which is the same as function (a, b, c) { return a + b * c; } Of course, this syntax breaks down if you want to return an object literal from your anonymous function. Curly braces are too overloaded in JS! Adding parentheses disambiguates between the new and the old function syntax.