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.
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+.
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.
- 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,//? $.fnreads 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.
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.
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
letread before its line. - user.address is undefined
- The path stopped early: there was nothing to read the next name from.
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.
TimelineEditing is paused while you replay · Esc to go back
Nothing in scope
everywhere
everywhere
in this loop
everywhere
in this loop
everywhere
in this loop
everywhere
in this loop
everywhere
everywhere
everywhere
everywhere
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.