Self World / Self → JavaScript

Write Self, get JavaScript

Self's objects, slots and prototypes are where JavaScript's came from, so Self translates to JavaScript naturally. Type Self on the left and the translation updates as you type. Run it, or download it as a web app: one HTML file, with the Self runtime and its whole starting world, that runs in any browser with no server and no install.

SELF
JAVASCRIPT Loading the translator…

    
Objects stay objects An object literal becomes $.obj([...]) with the same slots; a method becomes a JavaScript function; a message becomes $.send(receiver, "selector", [arguments]), looked up through parent slots at run time just like Self.
Blocks are closures Locals and arguments become JavaScript variables, blocks become arrow functions, and ^ inside a block returns from its method. Integers are BigInts, so 100 factorial is exact.
The whole world comes along The starting world (numbers, strings, collections, morphs…) is itself written in Self and translated the same way. A web app's morphs are drawn with the browser's own buttons, fields and canvases.
Also on the desktop In Self World: '3 + 4' asJavaScript, '…' asWebAppTitled: 'My app', World ▸ Export a Self file as a web app…, or self-world --web-app app.self.