Predict Pick Utility Output
Predict Output Medium
Question
What does this code print?
Code
interface User { id: number; name: string; email: string; }
type UserPreview = Pick<User, "id" | "name">;
const preview: UserPreview = { id: 1, name: "Bob" };
console.log(preview.id);
console.log(preview.name);
Hint
Pick selects only the specified properties from the original type.
Explanation
Pick<User, "id" | "name"> creates a type with only id and name properties (email is excluded). The preview object has id=1 and name="Bob". Output: 1 and Bob on separate lines.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.