MenuEveryday / Peek

Docs / Everyday

Peek

Add //? to a line, and after the Run, JSpark shows the value of that line beside it.

On this page

A Peek is a comment that asks for a value. JSpark draws the answer after the comment and never writes it into your Snippet. Peeks are filled on every Run, Run as you type included, in Node Snippets and in web pages.

See one value

End a line with //?. After the Run, the line's value appears beside it.

The loop ran four times; 53 is the value from the last pass.

When a line runs more than once, the value shown is the last one. Hover the value to open it, as the console opens a printed object.

Every pass JSpark+

In JSpark+, the hover also lists the value from each pass, in order, and how many times the line ran. For a line that ran many times, it lists the first few and the last few:0, 1, 2 … 97, 98, 99 (×100). In JSpark, the hover shows the last value, and says that every pass needs JSpark+.

Hovering → 53 lists every pass: 12, 19, 49, 53, four in all.

See part of the value

After code, write an expression of $, the line's value: //? $.length, //? JSON.stringify($). The Peek shows what the expression comes to.

Each Peek reads $, the value of its line. There is no users[2], so $.name threw.
  • It works only after code on the same line, not on a line of its own or in a /*? block.
  • The expression must read $. If your code has its own $, such as jQuery, //? $.fn reads that $, as a name does.
  • It is written in the Snippet's Language: //? $ as string[] works in TypeScript, and is only a comment in JavaScript.
  • A comment after it is not part of it: //? $.length // three words.
  • If the expression throws, the Peek shows the error, and the Run goes on.
  • The expression runs with your code, each time the line runs, so it can change what it touches: //? $.pop() takes the last item out. One that reaches outside, such as //? fetch($), is Outside Access: the Snippet then waits for you to press Run.

Name what to see

Write //? and a name on a line of its own to see that name's value at that point: //? prices. Put the same Peek before and after a line to see what the line changed.

sort() changed the array itself, and sorted the numbers as text.

On a line of its own, a Peek takes a name or a property path, such as //? user.name.

Several names at once

A block comment that starts with /*? takes one name on each line.

The spread copied name, but both objects share one tags array.

When there is no value

A Peek always says something, in lighter slanted text when it isn't a value:

not reached
The Run never got to the line.
not reached yet
It still may: a page keeps running, and in the Timeline a later Step may reach it.
not reached before stop
The Run was stopped, or ran out of time, first.
not set yet
The name exists but has no value yet, like a let read before its line.
user.address is undefined
The path stopped early: there was nothing to read the next name from.
The loop body never ran, so the Peek says not reached.

Peek in the Timeline

In the Timeline, a Peek shows its value at the Step on screen, so it changes as you move through the Steps.

Step by Step, the Peek shows 12, 19 and 49, and not reached yet before the loop.

Good to know

  • Peek values aren't saved with the Snippet. After you close the tab, the next Run brings them back.
  • Copying code copies the comment, not the value.
  • A value longer than 60 characters is cut short. Hover it to see all of it.

The pictures show JSpark on a Mac. On Windows, the window buttons are at the top right, the menus are in theMenu button at the left end of the tabs, and shortcuts use Ctrl where a Mac uses ⌘. The rest works the same way.

Esc

Type to search every docs page.

JSpark is downloading

When you open JSpark-Setup.exe, Windows may stop it once, because the installer isn’t code-signed yet. If the file came from jspark.app:

A blue Windows box, “Windows protected your PC”: Microsoft Defender SmartScreen prevented an unrecognised app from starting. Under it, the link More info, and the button Don’t run.

1Click More info.

The same box after More info: Application JSpark-Setup-1.4.0.exe, Publisher Unknown publisher, and the buttons Run anyway and Don’t run.

2Then click Run anyway.

You see this only once: updates install inside the app. More in Install JSpark.