Explain code, execution flow and side effects
Understand what existing code accepts, returns and changes, without asking for an unnecessary rewrite.
Use this prompt
What to provide
- The code, its language and relevant runtime or library versions.
- Enough surrounding context to understand referenced functions and values.
Example Illustrative example
Input
Illustrative editorial example — not a recorded model test. JavaScript: const doubled = [1, 2, 3].map(n => n * 2); Detail level: beginner.
Output
The array contains 1, 2 and 3. map calls the supplied function for each value and creates a new array from the returned values. Multiplication by 2 produces doubled = [2, 4, 6]. The expression does not perform network or file operations. This explanation assumes standard JavaScript Array.map behaviour.
Improve the result
- List what cannot be determined from this snippet and suggest small checks to confirm its behaviour.