{
  "id": 15914877,
  "title": "Every value should know where it came from",
  "url": "https://urgent.news/2026/10/21/every-value-should-know-where-it-came-from",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-21T16:51:08.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/jslab/every-value-should-know-where-it-came-from-ofb"
  },
  "original_language": "en",
  "account": "When you run your code, a value may print out, but where did it originate? If you find yourself stopping to ponder, this article is for you. It introduces a simple concept that can enhance feedback loops: every value should carry the address of the line that produced it. In a basic script, an array of objects is defined, and certain values are filtered and reduced to calculate revenue and average. The final output shows the number of paid orders, the total revenue, and the average order value. However, these three numbers lack any trace of their origin. If the script grew to 300 lines with numerous console.log statements, tracing back the source of each output would become increasingly challenging. The proposed solution is to anchor every result, log, and error to the corresponding line number. This approach has three benefits: it eliminates the need for manual labels, enables bidirectional navigation between the output and the editor, and provides an address for errors in stack traces. JSLab, a JavaScript and TypeScript scratchpad for macOS, implements this concept. When running code in JSLab, each result, log, and error is displayed alongside the line that produced it. The output panel offers filtering options for results, logs, and errors, and the count is always visible, even when it's zero. Anchoring output to source lines reduces the need for manual logging. By appending //? to an expression, its value is logged next to its line. The editor also supports magic comments for logging values within expressions, and a toolbar with $ as a placeholder. Logpoints allow logging without modifying the code; clicking the gutter or pressing F9 on a line logs that line every time it runs. Even if the script encounters an error, the line number is displayed, along with linked stack frames pointing to the relevant code. Anchored output is most beneficial when errors occur. In JSLab, errors are highlighted and linked to the corresponding source lines, making it easier to identify and fix issues. For further inspection, objects, arrays, Maps, and Sets can be expanded one level at a time, with a full expansion option available. Right-clicking a value allows copying it in various formats, such as plain text or JSON. While JSLab runs code in a separate process to avoid interference with the editor, it is optimized for Apple Silicon Macs running macOS 14 or later. A 14-day free trial is available, and the software is set to launch in November.",
  "summary": "You run your code. Something prints 42 . Which line printed it? If you had to stop and think, this post is for you. It's about one small idea that makes feedback loops better: every value should carry the address of the line that produced it. The problem with a flat list Here's a small script. Nothing exotic. const orders = [ { id : 1 , total : 40 }, { id : 2 , total : 15 }, { id : 3 , total : 0…",
  "key_points": [],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}