Magic Comments
Magic comments log the value of an expression to the output pane without modifying what your code does. Add //? after a statement to print its value:
[1, 2, 3].map(n => n * 2) //?
The block form /*?*/ can be used inline, mid-expression:
a.b().c() /*?*/ .d()
It also works before the opening brace of a block — useful for inspecting the condition of an if or each iteration of a loop:
if (user.role === 'admin') /*?*/ {
// ...
}
for (const item of items) /*?*/ {
// ...
}
Anything written after the marker is evaluated as JavaScript, with $ referring to the value of the expression. Use this to log a derived value instead of the whole thing:
users //? $.map(u => u.name)
items.filter(i => i.active) //? $.length