JavaScript

JavaScript Expression Evaluator

Evaluates one expression per line and shows the result of each beside it.

Loading the tool…

Processing happens locally in your browser. What you paste or load is processed by this page and is not uploaded to a server. Nothing is stored unless you use a control that says it stores something, and you can clear anything this site has kept from the privacy page.

How to use this tool

  1. Write one expression per line. Blank lines and lines starting with // are ignored.
  2. Declare a name on an early line if later lines need it — const, let, var, function and class lines all work, and every line shares one sandbox.
  3. Select Evaluate every line.
  4. Copy the table, or download it as CSV to keep the results beside the expressions.

What javascript expression evaluator does

Opening the browser console to check what `0.1 + 0.2` gives, or what `[..."hello"].reverse().join("")` produces, means losing whatever you were looking at. This page is the scratchpad instead: write one expression per line and every answer appears beside its expression in a table you can copy or download as CSV.

All the lines are evaluated in a single sandbox, in order, so a line that declares something — const, let, var, function or class — is emitted as a real declaration and the name is still in scope further down, which is how a scratchpad is actually used. A declaration line shows the value it was given. An expression that throws does not stop the rest; its error is shown in place and the run continues, so one typo does not cost you the other nineteen answers. Values are formatted rather than stringified, so an array stays an array and an object shows its keys.

Frequently asked questions

Yes. All the lines are evaluated in one sandbox, in order, so a const or function declared on line three is in scope on line ten. Declaration lines are emitted as statements rather than wrapped as expressions, which is what makes the name survive; the row for that line shows the value it was given. The example on this page relies on it.

That line shows its error and the rest of the run continues. A single typo does not cost you the other answers. The summary tells you how many threw so you can spot them quickly in a long list.

Results are formatted the way a developer console shows them, not stringified as JSON. That keeps functions, dates, maps, sets and circular references readable instead of throwing or vanishing. If you want JSON, wrap the expression in JSON.stringify yourself.