What is a first‑class function?
💡 Model Answer
A first‑class function is a function that is treated as a first‑class citizen in a programming language. This means it can be assigned to variables, passed as arguments to other functions, returned from functions, and stored in data structures. Languages that support first‑class functions—such as JavaScript, Python, and Scala—allow developers to write higher‑order functions and functional‑style code. For example, in JavaScript you can write const add = (x, y) => x + y; and then pass add to another function: const result = applyOperation(add, 2, 3);. This flexibility enables powerful abstractions like callbacks, currying, and function composition, which are central to functional programming paradigms.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers — invisible to screen sharing.
Get Assisting AI — Starts at ₹500