Senior JavaScript Interviews: Understanding this and Arrow Functions

👉 Solve below o/p based question if u beileve u have good understanding of JS Concepts" 🚨 I’ve appeared for multiple senior full-stack interviews recently, and "this" based quetion are must ask: 🚨 Senior-Level JavaScript Interviews Are NOT About Syntax — They’re About Understanding " .. .... ....... Here are a couple of commonly asked (and often confusing) questions 👇 🧠 Q1: Understanding this and Arrow Functions let obj = { name: "Ravi", fn: function () { console.log(this.name); }, arrFn: function () { (() => { console.log(this.name); })(); }, }; obj.fn(); obj.arrFn(); 💡 Concepts being tested: this binding in regular functions Lexical this in arrow functions Execution context Method invocation vs inner function 👉 Key Insight: Arrow functions don’t have their own this — they inherit it from their surrounding scope. ------------------------------------------------------------------- 🧠 Q2: Classes, Binding, and Function References class Person { age = 20; constructor(name) { this.name = name; this.func = this.func.bind(this); } func() { console.log(this.name); } arrowFunc = () => { console.log(this.name, this.age); }; } const person1 = new Person("Rahul"); person1.func(); person1.arrowFunc(); const copyFn = person1.func; copyFn(); 💡 Concepts being tested: Class fields & initialization Explicit binding using .bind(this) Difference between normal methods vs arrow functions in classes Function reference vs method call How "this" behaves when function is detached Do you really understand this? Can you predict output without running the code? 💬 If you’re preparing for senior roles, don’t just “know” JavaScript — understand its behavior in edge cases. #javascript #frontend #fullstack #webdevelopment #interviewprep #reactjs #nodejs #softwareengineering #codinginterview #jsconcepts

To view or add a comment, sign in

Explore content categories