Arrow Functions — JS Technical Interview Questions & Answers
Concise syntax with lexical this binding.
Arrow Functions
- Arrow Functions (js) is a JS topic. In plain words you use it for add(a, b) in a checkout total. Don’t start with a slogan — start with that picture.
- Smallest example: function add / const add = () =>. Type it, run it, and say what you see. If you can do that from memory, you know Arrow Functions (js).
- From the example next to this theory: Concise syntax with lexical this binding.
- Trap: this surprise in arrow vs function. Fix that before you talk about advanced JS.
- Viva: what is Arrow Functions (js)? Then show function add / const add = () =>. Then name the trap.
Technical Interview Tip: What is Arrow Functions (js)? Show this: function add / const add = () =>. Trap: this surprise in arrow vs function.
Code Examples for Arrow Functions
Arrow Functions — working example
const add = (a, b) => a + b;
const name = "Ada";
console.log(`Hi, ${name}!`);
const user = { name: "Lin", city: "Pune", skills: ["CSS"] };
const { city, ...rest } = user;
const skills = [...user.skills, "JS"];
console.log(add(2, 3), city, rest, skills);
console.log(user.profile?.bio ?? "n/a");Arrow Functions — modern JS: arrows, template strings, destructuring, spread/rest, ?. and ?? for safe defaults.
How to Explain Arrow Functions to an Interviewer
What is Arrow Functions (js)?
Used for add(a, b) a checkout total Not just the heading
Give one small example of Arrow Functions (js).
function add / const add = () => Concise syntax with lexical this binding
What mistake do beginners make with Arrow Functions (js)?
this surprise in arrow vs function Show the fix
Where do you use Arrow Functions (js)?
a checkout total add(a, b)