5 ms·
Which language is used in the code boxes here? is this a JavaScript extension?
by glutamate 3y ago
Which language is used in the code boxes here? is this a JavaScript extension?
- glutamate 3y agoThe answer is probably in here https://observablehq.com/documentation/cells/observable-javascript https://observablehq.com/documentation/cells/observable-java... but i still don't see why you can do `x = { let y = 5; return y }`
- FragenAntworten 3y agoI think that's a combination of two features, named cells[1] and blocks[2]. [1] https://observablehq.com/documentation/cells/javascript#naming-referencing-cells https://observablehq.com/documentation/cells/javascript#nami... [2] https://observablehq.com/documentation/cells/javascript#expressions-variables-blocks https://observablehq.com/documentation/cells/javascript#expr...
- zokier 3y ago> Named cells look like, and function almost like, assignment expressions in vanilla JavaScript > But sometimes you want statements, such as for loops. For that you'll need curly braces, and a return statement to give the cell a value. Think of a cell as a function, except the function has no arguments So `x = { let y = 5; return y }` declares named cell x with value from the return value of that function-like code block. So basically that should be same as `x = 5`, which also is named cell declaration and not JS variable assignment.