💡 JavaScript Interview Question: Promise.all() vs Promise.allSettled() While preparing for frontend interviews, one question that often comes up is: 👉 What is the difference between Promise.all() and Promise.allSettled()? Here is a simple way to explain it in interviews. 🔹 Promise.all() Promise.all() takes multiple promises and runs them in parallel. It resolves only when all promises are successful. If any one promise fails, the entire Promise.all() fails immediately. 📌 Example const p1 = Promise.resolve("API 1 success"); const p2 = Promise.resolve("API 2 success"); const p3 = Promise.reject("API 3 failed"); Promise.all([p1, p2, p3]) .then(res => console.log(res)) .catch(err => console.log("Error:", err)); Output: Error: API 3 failed ✔️ When to use: When all results are required to proceed. Example: Loading multiple dependencies before rendering a page. 🔹 Promise.allSettled() Promise.allSettled() waits for all promises to complete, regardless of success or failure. It returns the status of each promise (fulfilled or rejected). 📌 Example Promise.allSettled([p1, p2, p3]).then(res => console.log(res)); Output: [ { status: "fulfilled", value: "API 1 success" }, { status: "fulfilled", value: "API 2 success" }, { status: "rejected", reason: "API 3 failed" } ] ✔️ When to use: When you want results from all APIs even if some fail. Example: Dashboard widgets where each API is independent. 🎯 How I answer this in interviews Promise.all() → fails fast if any promise fails. Promise.allSettled() → waits for all promises and returns each result. 💬 Follow-up interview question "What if you want successful responses even when some APIs fail?" Answer: Use Promise.allSettled() and filter fulfilled results. const results = await Promise.allSettled(promises); const success = results .filter(r => r.status === "fulfilled") .map(r => r.value); Understanding these small JavaScript concepts deeply can make a big difference in frontend interviews. #javascript #reactjs #frontenddeveloper #webdevelopment #interviewprep #mernstack
Promise.all() vs Promise.allSettled() in JavaScript
More Relevant Posts
-
⚡ Frontend Interview Cheat Sheet (Last-Minute Revision | Mid-Level) Got an interview in a few hours? This is your high-impact revision guide — not fluff, just what actually gets asked. Save it. Skim it. Walk in sharp. 💪 🧠 JavaScript Essentials (Core Thinking Area) 🔹 Closures → Function retains access to its lexical scope even after execution 👉 Used in: data privacy, currying, memoization 🔹 Event Loop → Handles async execution Call Stack → executes sync code Microtasks → Promises (then, catch) Macrotasks → setTimeout, setInterval 👉 Microtasks run before macrotasks 🔹 this keyword Depends on how function is called Arrow functions → no own this (inherits from parent) 🔹 Prototypes & Inheritance JS uses prototypal inheritance, not classical Objects can inherit properties via __proto__ 🔹 Async Patterns Callbacks → Promises → Async/Await Always handle errors (try/catch or .catch) 🔹 Debounce vs Throttle Debounce → wait for inactivity (search input) Throttle → limit frequency (scroll events) ⚛️ React Deep Recall (Most Asked Section) 🔹 Rendering Flow 👉 State/props change → Virtual DOM → Diffing → Reconciliation → DOM update 🔹 useEffect Mastery Runs after render Dependency array controls execution Cleanup function prevents memory leaks 🔹 Re-renders (CRITICAL) Caused by: State changes Parent re-renders 👉 Optimize using React.memo, useMemo, useCallback 🔹 State Management Thinking Local state vs global state (Context/Redux) Lift state up when multiple components need it 🔹 Controlled vs Uncontrolled Controlled → React manages form state Uncontrolled → DOM manages state (refs) 🔹 Common Pitfall 👉 Updating state is async — don’t rely on immediate value 🌐 Browser & Performance (Where You Stand Out) 🔹 What happens when you type a URL? DNS → TCP handshake → HTTP request → Server → Response → Rendering 🔹 Rendering Optimization Minimize reflows & repaints Avoid large DOM trees Use requestAnimationFrame for animations 🔹 Storage localStorage → persistent sessionStorage → per tab Cookies → sent with every request 🔹 CORS Browser security policy Controlled via server headers 🔹 Performance Techniques Lazy loading (images/components) Code splitting (dynamic import) Tree shaking CDN usage 🎨 HTML & CSS (Don’t Underestimate) 🔹 Box Model → content + padding + border + margin 🔹 Flexbox vs Grid Flexbox → 1D layouts (row/column) Grid → 2D layouts (rows + columns) 🔹 Positioning relative, absolute, fixed, sticky → know differences 🔹 Specificity Order Inline > ID > Class > Element 🔹 Display Differences display: none → removes from layout visibility: hidden → keeps space 🔹 Accessibility (A11y) 👉 Semantic tags, alt text, keyboard navigation #FrontendDevelopment #JavaScript #ReactJS #InterviewPrep #WebDevelopment #SoftwareEngineering #Developers #TechCareers #CodingInterview #CareerGrowth #FrontendEngineer
To view or add a comment, sign in
-
⚡ Frontend Interview Cheat Sheet (Last-Minute Revision | Mid-Level) Got an interview in a few hours? This is your high-impact revision guide — not fluff, just what actually gets asked. Save it. Skim it. Walk in sharp. 💪 🧠 JavaScript Essentials (Core Thinking Area) 🔹 Closures → Function retains access to its lexical scope even after execution 👉 Used in: data privacy, currying, memoization 🔹 Event Loop → Handles async execution Call Stack → executes sync code Microtasks → Promises (then, catch) Macrotasks → setTimeout, setInterval 👉 Microtasks run before macrotasks 🔹 this keyword Depends on how function is called Arrow functions → no own this (inherits from parent) 🔹 Prototypes & Inheritance JS uses prototypal inheritance, not classical Objects can inherit properties via __proto__ 🔹 Async Patterns Callbacks → Promises → Async/Await Always handle errors (try/catch or .catch) 🔹 Debounce vs Throttle Debounce → wait for inactivity (search input) Throttle → limit frequency (scroll events) ⚛️ React Deep Recall (Most Asked Section) 🔹 Rendering Flow 👉 State/props change → Virtual DOM → Diffing → Reconciliation → DOM update 🔹 useEffect Mastery Runs after render Dependency array controls execution Cleanup function prevents memory leaks 🔹 Re-renders (CRITICAL) Caused by: State changes Parent re-renders 👉 Optimize using React.memo, useMemo, useCallback 🔹 State Management Thinking Local state vs global state (Context/Redux) Lift state up when multiple components need it 🔹 Controlled vs Uncontrolled Controlled → React manages form state Uncontrolled → DOM manages state (refs) 🔹 Common Pitfall 👉 Updating state is async — don’t rely on immediate value 🌐 Browser & Performance (Where You Stand Out) 🔹 What happens when you type a URL? DNS → TCP handshake → HTTP request → Server → Response → Rendering 🔹 Rendering Optimization Minimize reflows & repaints Avoid large DOM trees Use requestAnimationFrame for animations 🔹 Storage localStorage → persistent sessionStorage → per tab Cookies → sent with every request 🔹 CORS Browser security policy Controlled via server headers 🔹 Performance Techniques Lazy loading (images/components) Code splitting (dynamic import) Tree shaking CDN usage 🎨 HTML & CSS (Don’t Underestimate) 🔹 Box Model → content + padding + border + margin 🔹 Flexbox vs Grid Flexbox → 1D layouts (row/column) Grid → 2D layouts (rows + columns) 🔹 Positioning relative, absolute, fixed, sticky → know differences 🔹 Specificity Order Inline > ID > Class > Element 🔹 Display Differences display: none → removes from layout visibility: hidden → keeps space 🔹 Accessibility (A11y) 👉 Semantic tags, alt text, keyboard navigation #FrontendDevelopment #JavaScript #ReactJS #InterviewPrep #WebDevelopment #SoftwareEngineering #Developers #TechCareers #CodingInterview #CareerGrowth #FrontendEngineer
To view or add a comment, sign in
-
🚀 Out-of-the-Box React Interview Questions (UAE Edition 🇦🇪) Not your usual “what is useState?” — these are the questions that actually test senior thinking 👇 1️⃣ Why can overusing useMemo/useCallback actually make your app slower? 👉 Because memoization itself has a cost (memory + comparison) 👉 If the computation is cheap, memoization becomes overhead 💡 Use them only when re-render cost > memo cost 2️⃣ How would you design a React app that works even with poor internet (common real-world UAE scenario)? ✔️ Cache API responses (service workers) ✔️ Use skeleton loaders instead of spinners ✔️ Implement retry + graceful fallback UI ✔️ Lazy load non-critical features 💡 This shows product thinking, not just coding 3️⃣ What happens if you update state inside render()? 👉 Infinite re-render loop 😵 👉 React keeps re-triggering render 💡 This question checks if you understand React lifecycle deeply 4️⃣ Why is using index as a key dangerous in lists? 👉 Causes incorrect UI updates when list order changes 👉 React can't properly track elements 💡 Leads to subtle bugs — interviewers love this one 5️⃣ How would you detect unnecessary re-renders without React DevTools? ✔️ Add console logs strategically ✔️ Use custom hooks to track renders ✔️ Track prop changes manually 💡 Shows debugging mindset beyond tools 6️⃣ If a component re-renders but props didn’t change — why? 👉 Parent re-render 👉 New reference values (objects/functions) 👉 Context updates 💡 Understanding reference equality is key 7️⃣ How would you handle feature flags in React for different users? ✔️ Store flags in config/context ✔️ Toggle UI/features dynamically ✔️ Fetch flags from backend 💡 Very common in large UAE fintech / product companies 8️⃣ Why shouldn’t you store derived data in state? 👉 Causes unnecessary re-renders 👉 Risk of data inconsistency 💡 Instead, compute it from existing state 9️⃣ How would you secure a React app if everything is exposed in frontend? 👉 Never trust frontend alone ✔️ Validate on backend ✔️ Use short-lived tokens ✔️ Role-based access control 💡 Tests real-world security awareness 🔟 How would you debug a memory leak in React? ✔️ Check uncleaned useEffect (event listeners, intervals) ✔️ Abort API calls ✔️ Use cleanup functions 💡 Critical for long-running apps 🔥 These are the questions that separate mid vs senior developers 💬 Which one caught you off guard? #ReactJS #FrontendDeveloper #AdvancedReact #ReactInterview #UAEJobs #TechInterview #JavaScript #WebDevelopment #PerformanceOptimization #Debugging #SoftwareEngineering #FrontendArchitecture #DevelopersLife
To view or add a comment, sign in
-
🚀 Angular Interview Guide:Advanced Level Ready for a deep dive? After the basics, interviewers often look for your understanding of performance, security, and state management. Here are the next crucial Angular questions! 🔐 Security & Communication 1️⃣ How to prevent XSS in Angular? Angular has built-in sanitization. Use DomSanitizer if you need to bypass it for trusted values. 2️⃣ Cross-Component Communication: Use @Input/@Output, Services (Subjects), or State Management (Signals/NgRx). 3️⃣ HTTP Client: A module to perform HTTP requests that returns Observables instead of Promises. 4️⃣ Resolver Guards: Used to pre-fetch data before a route is activated so the page doesn't load empty. 5️⃣ What is Shadow DOM? A web standard that Angular uses (via ViewEncapsulation.ShadowDom) to isolate component styles completely. 🚀 Optimization & Performance 6️⃣ TrackBy in ngFor: A function used to improve performance by telling Angular how to identify unique items, avoiding re-rendering the whole list. 7️⃣ Tree Shaking: The process of removing unused code from the final bundle during build to reduce file size. 8️⃣ NgZone (Zone.js): The library Angular uses to detect changes. For heavy tasks, use runOutsideAngular to improve speed. 9️⃣ Web Workers in Angular: Used to run heavy computations in a background thread without freezing the UI. 10️⃣ Server-Side Rendering (SSR): Using Angular Universal to render pages on the server for better SEO and faster first paint. 🧪 Testing & Architecture 11️⃣ Component Testing: Using Jasmine and Karma to test component logic and UI behavior. 12️⃣ Protractor vs Cypress: Tools for End-to-End (E2E) testing. Cypress is currently the more popular choice for modern apps. 13️⃣ Transclusion (ng-content): A way to pass HTML content from a parent component into a specific spot in a child component. 14️⃣ ProvidedIn: 'root': A way to create a singleton service that is available application-wide without adding it to a module. 15️⃣ APP_INITIALIZER: A special token that allows you to run code (like fetching config) before the app starts. 🔄 Modern Angular & State 16️⃣ Standalone Components: (Latest!) Components that don't require an NgModule, making the app more lightweight. 17️⃣ Deferrable Views (@defer): A modern way to declaratively lazy-load parts of a template to boost performance. 18️⃣ RxJS Operators (SwitchMap vs MergeMap): SwitchMap: Cancels previous request (best for searches). MergeMap: Handles all requests in parallel. 19️⃣ State Management (NgRx/NGXS): Libraries for managing global state in very large, complex applications. 20️⃣ What is a Custom Directive? Creating your own directive using @Directive to add custom behavior to elements (e.g., a directive to auto-focus an input). 💡 Which part of Angular should I cover next? Let’s connect and grow! #Angular #AdvancedAngular #WebDevelopment #FrontendEngineering #FullStack #CodingInterview #AngularSignals #CleanCode
To view or add a comment, sign in
-
🎯 10 Interview Questions I’ve Seen Frequently for .NET / Full-Stack Developer Roles If you're preparing for a .NET / Angular / Full-Stack Developer interview, don’t just memorize syntax. Most interviews are designed to test how you think, not just what you know. Here are 10 commonly asked questions I keep seeing 👇 1️⃣ What is the difference between IEnumerable and IQueryable in .NET? This question checks if you understand: Deferred execution Database querying Performance implications 2️⃣ Explain the difference between async/await, multithreading, and parallelism A very common one — especially for backend roles. Interviewers want to know if you truly understand: Concurrency Scalability Non-blocking operations 3️⃣ What is Dependency Injection, and why is it useful? This is almost guaranteed in modern .NET interviews. Be ready to explain: Loose coupling Testability Service lifetimes (Transient, Scoped, Singleton) 4️⃣ What happens in the Angular component lifecycle? A frequent Angular question. You should be comfortable with: ngOnInit ngOnChanges ngOnDestroy And more importantly — when to use them. 5️⃣ What is the difference between Authentication and Authorization? Very common for full-stack roles. This usually leads into: JWT Role-based access API security 6️⃣ How would you improve the performance of a slow API? This is where practical experience matters. Good answers may include: Caching Query optimization Pagination Async I/O Logging & profiling 7️⃣ What is the difference between Reactive Forms and Template-Driven Forms in Angular? Classic Angular interview question. This tests: Form architecture understanding Validation strategies Real-world usage decisions 8️⃣ What are SOLID principles, and have you used them in real projects? A lot of candidates can define SOLID. Fewer can explain where they actually applied it. That’s what interviewers really care about. 9️⃣ How do you handle exceptions and logging in a .NET API? This question checks if you think like someone who has worked in production. Be ready to talk about: Middleware Global exception handling Structured logging 🔟 Tell me about a challenging bug or production issue you solved This one is underrated — but very important. Because this question reveals: Your debugging mindset Your ownership How you behave under pressure 💡 Best interview prep advice? Don’t just prepare definitions. Prepare: Examples Trade-offs Why you made certain decisions That’s what makes answers stand out. Which interview question do you think candidates struggle with the most? 👇 #DotNetDeveloper #AngularDeveloper #SoftwareEngineering #TechInterviews #FullStackDeveloper #BackendDevelopment #FrontendDevelopment #CareerGrowth
To view or add a comment, sign in
-
-
🚀 Out-of-the-Box Angular Interview Questions (UAE Edition 🇦🇪) Not the usual “what is component?” — these are questions that test real Angular expertise 👇 1️⃣ Why can excessive use of RxJS operators make your Angular app harder to maintain? 👉 Chaining too many operators (switchMap, mergeMap, concatMap) can make logic unreadable 👉 Debugging becomes complex due to async streams 💡 Clean streams > complex pipelines 2️⃣ Why is subscribing inside a subscribe considered a bad practice? 👉 Leads to nested subscriptions (callback hell) 👉 Hard to manage and can cause memory leaks 💡 Use higher-order mapping operators like switchMap instead 3️⃣ What happens if you don’t unsubscribe from Observables? 👉 Memory leaks 😵 👉 Background processes continue even after component destroy 💡 Use async pipe or takeUntil / takeUntilDestroyed 4️⃣ How does Change Detection actually impact performance? 👉 Angular checks bindings on every change detection cycle 👉 Default strategy checks entire component tree 💡 Use OnPush to optimize and reduce unnecessary checks 5️⃣ Why can using too many services create hidden issues? 👉 Tight coupling between components and services 👉 Harder to track data flow 💡 Design services with clear responsibility 6️⃣ What’s the real problem with using any type everywhere? 👉 Loses TypeScript advantages 👉 Increases runtime bugs 👉 Makes code less predictable 💡 Strong typing = safer and scalable apps 7️⃣ How would you debug a slow Angular app in production? ✔️ Use Chrome DevTools Performance tab ✔️ Analyze bundle size ✔️ Check change detection cycles ✔️ Look for heavy computations in templates 💡 Templates should stay lightweight 8️⃣ Why are functions in templates dangerous? 👉 Called on every change detection cycle 👉 Can severely impact performance 💡 Use computed values instead 9️⃣ How would you implement role-based UI access? ✔️ Store roles in service or state ✔️ Use guards for routing ✔️ Conditionally render UI 💡 Very common in enterprise UAE apps 🔟 How would you handle global error handling in Angular? ✔️ Use HttpInterceptor for API errors ✔️ Create global ErrorHandler class ✔️ Log errors to monitoring tools 💡 Shows production-level thinking 1️⃣1️⃣ Why can large modules slow down Angular apps? 👉 Everything gets loaded upfront 👉 Increases initial bundle size 💡 Use lazy loading to split modules 1️⃣2️⃣ How would you structure a scalable Angular project? ✔️ Feature-based modules ✔️ Shared module for reusable components ✔️ Core module for singleton services 💡 Architecture questions are very common for senior roles 🔥 These questions test real Angular depth — not just basics 💬 Which one do you struggle with the most? #Angular #FrontendDeveloper #AngularInterview #UAEJobs #TechInterview #RxJS #WebDevelopment #PerformanceOptimization #SoftwareEngineering #FrontendArchitecture #DevelopersLife
To view or add a comment, sign in
-
🚀 25 Angular Interview Questions & Answers Whether you're preparing for interviews or brushing up your Angular skills, here are 25 crisp Q&A you can quickly revise 👇 --- 🔹 Basics 1. What is Angular? A TypeScript-based front-end framework for building scalable web applications. 2. What is a Component? The basic building block of Angular UI, consisting of HTML, CSS, and TypeScript. 3. What is a Module (NgModule)? A container that groups components, directives, pipes, and services. 4. What is Data Binding? Sync between UI and data (one-way or two-way). 5. Types of Data Binding? - Interpolation "{{}}" - Property Binding "[ ]" - Event Binding "( )" - Two-way Binding "[(ngModel)]" --- 🔹 Intermediate 6. What are Directives? Instructions that modify DOM behavior (ngIf, ngFor). 7. Types of Directives? - Structural - Attribute - Component 8. What is Dependency Injection (DI)? A design pattern to inject services into components. 9. What is a Service? Reusable logic shared across components. 10. What is Routing? Navigation between different views/pages. --- 🔹 Advanced 11. What is Lazy Loading? Loading modules only when needed to improve performance. 12. What is AOT Compilation? Compiling Angular code during build time instead of runtime. 13. What is Change Detection? Mechanism to update UI when data changes. 14. What is Zone.js? Tracks async operations to trigger change detection. 15. What are Pipes? Transform data in templates (e.g., date, currency). --- 🔹 Practical Concepts 16. What is Reactive Forms? Form handling using FormControl & FormGroup. 17. Template-driven vs Reactive Forms? Template → Simple Reactive → Scalable & testable 18. What is HttpClient? Service to make API calls. 19. What is RxJS? Library for reactive programming using Observables. 20. What is an Observable? Handles async data streams. --- 🔹 Pro Level 21. What is TrackBy in ngFor? Improves performance by tracking items uniquely. 22. What is ViewChild? Access child components/directives in TS. 23. What is Angular CLI? Tool to create and manage Angular projects. 24. What is Standalone Component? Component without NgModule (Angular 14+). 25. What is Signals (Angular latest)? New reactive state management system. --- 🔥 Pro Tip: Don’t just memorize—build projects using these concepts. 🔁 Save & Share to help others #Angular #WebDevelopment #Frontend #Programming #InterviewPrep #Developers
To view or add a comment, sign in
-
-
Not everyone who reads will buy. And that’s completely fine. But here’s something I’ve noticed: Many developers go through interview questions, understand the topic, and still struggle in actual interviews. Because knowing is different from explaining. If you’re preparing for .NET or Angular interviews and feel like: - “I know this, but I can’t explain it properly” - “I get stuck in follow-up questions” - “I’m almost ready, but not confident” Then this guide is designed exactly for that gap. It’s not about more questions. It’s about understanding them the right way. Keeping it at a launch price for a few more days. Link: https://lnkd.in/dfTnJFM7 #dotnet #angular #softwaredeveloper #fullstackdeveloper #interviewpreparation #csharp
To view or add a comment, sign in
-
🚫 𝗧𝗵𝗶𝘀 𝗶𝘀 𝘄𝗵𝗲𝗿𝗲 𝗺𝗼𝘀𝘁 𝗱𝗲𝘃𝗲𝗹𝗼𝗽𝗲𝗿𝘀 𝗙𝗔𝗜𝗟 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗶𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄𝘀. Not because the questions are hard… But because the concepts are deceptively simple. Let’s test your depth 👇 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝟭: 𝗙𝘂𝗻𝗰𝘁𝗶𝗼𝗻 + 𝗛𝗼𝗶𝘀𝘁𝗶𝗻𝗴 𝗧𝗿𝗮𝗽 𝑣𝑎𝑟 𝑥 = 1; 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑡𝑒𝑠𝑡() { 𝑐𝑜𝑛𝑠𝑜𝑙𝑒.𝑙𝑜𝑔(𝑥); 𝑣𝑎𝑟 𝑥 = 2; } 𝑡𝑒𝑠𝑡(); 𝗢𝘂𝘁𝗽𝘂𝘁: undefined 𝗘𝘅𝗽𝗹𝗮𝗻𝗮𝘁𝗶𝗼𝗻: Inside test, this happens: 👉 Local x shadows global x 👉 And it’s initialized as undefined 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝟮: 𝘁𝗵𝗶𝘀 𝗕𝗶𝗻𝗱𝗶𝗻𝗴 (𝗥𝗲𝗮𝗹 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄 𝗙𝗮𝘃𝗼𝗿𝗶𝘁𝗲) 𝑐𝑜𝑛𝑠𝑡 𝑢𝑠𝑒𝑟 = { 𝑛𝑎𝑚𝑒: "𝑆ℎ𝑢𝑏ℎ𝑎𝑚", 𝑔𝑟𝑒𝑒𝑡() { 𝑐𝑜𝑛𝑠𝑜𝑙𝑒.𝑙𝑜𝑔(𝑡ℎ𝑖𝑠.𝑛𝑎𝑚𝑒); } }; 𝑐𝑜𝑛𝑠𝑡 𝑔𝑟𝑒𝑒𝑡𝐹𝑛 = 𝑢𝑠𝑒𝑟.𝑔𝑟𝑒𝑒𝑡; 𝑔𝑟𝑒𝑒𝑡𝐹𝑛(); 𝗢𝘂𝘁𝗽𝘂𝘁: undefined 𝗘𝘅𝗽𝗹𝗮𝗻𝗮𝘁𝗶𝗼𝗻: • Function is called without object context • this → global object (or undefined in strict mode) 👉 this depends on how function is called, not where it's defined 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝟯: == 𝘃𝘀 === 𝗠𝗶𝗻𝗱 𝗧𝗿𝗮𝗽 𝑐𝑜𝑛𝑠𝑜𝑙𝑒.𝑙𝑜𝑔(𝑛𝑢𝑙𝑙 == 𝑢𝑛𝑑𝑒𝑓𝑖𝑛𝑒𝑑); 𝑐𝑜𝑛𝑠𝑜𝑙𝑒.𝑙𝑜𝑔(𝑛𝑢𝑙𝑙 === 𝑢𝑛𝑑𝑒𝑓𝑖𝑛𝑒𝑑); 𝗢𝘂𝘁𝗽𝘂𝘁: true, false 𝗘𝘅𝗽𝗹𝗮𝗻𝗮𝘁𝗶𝗼𝗻: • == → loose equality (special rule: null & undefined are equal) • === → strict equality (type must match) 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝟰: 𝗔𝗿𝗿𝗮𝘆 𝗟𝗲𝗻𝗴𝘁𝗵 𝗧𝗿𝗮𝗽 𝑐𝑜𝑛𝑠𝑡 𝑎𝑟𝑟 = [1, 2, 3]; 𝑎𝑟𝑟.𝑙𝑒𝑛𝑔𝑡ℎ = 0; 𝑐𝑜𝑛𝑠𝑜𝑙𝑒.𝑙𝑜𝑔(𝑎𝑟𝑟); 𝗢𝘂𝘁𝗽𝘂𝘁: [] 𝗘𝘅𝗽𝗹𝗮𝗻𝗮𝘁𝗶𝗼𝗻: Setting length = 0 clears the array 👉 This is actually used in real apps for quick reset 𝗤𝘂𝗲𝘀𝘁𝗶𝗼𝗻 𝟱: 𝗣𝗿𝗼𝗺𝗶𝘀𝗲 + 𝗘𝗿𝗿𝗼𝗿 𝗛𝗮𝗻𝗱𝗹𝗶𝗻𝗴 𝑃𝑟𝑜𝑚𝑖𝑠𝑒.𝑟𝑒𝑗𝑒𝑐𝑡("𝐸𝑟𝑟𝑜𝑟") .𝑡ℎ𝑒𝑛(() => 𝑐𝑜𝑛𝑠𝑜𝑙𝑒.𝑙𝑜𝑔("𝑆𝑢𝑐𝑐𝑒𝑠𝑠")) .𝑐𝑎𝑡𝑐ℎ((𝑒𝑟𝑟) => { 𝑐𝑜𝑛𝑠𝑜𝑙𝑒.𝑙𝑜𝑔(𝑒𝑟𝑟); 𝑟𝑒𝑡𝑢𝑟𝑛 "𝑅𝑒𝑐𝑜𝑣𝑒𝑟𝑒𝑑"; }) .𝑡ℎ𝑒𝑛((𝑟𝑒𝑠) => 𝑐𝑜𝑛𝑠𝑜𝑙𝑒.𝑙𝑜𝑔(𝑟𝑒𝑠)); 𝗢𝘂𝘁𝗽𝘂𝘁: Error Recovered 𝗘𝘅𝗽𝗹𝗮𝗻𝗮𝘁𝗶𝗼𝗻: • Rejected promise skips .then() • .catch() handles error & returns new value • Next .then() receives that value 💬 𝗪𝗵𝗮𝘁 𝗜𝗻𝘁𝗲𝗿𝘃𝗶𝗲𝘄𝗲𝗿𝘀 𝗔𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝗖𝗵𝗲𝗰𝗸 They don’t expect you to memorize outputs. They check if you understand: 👉 Execution context 👉 Scope & hoisting 👉 this binding 👉 Async flow If you can explain these confidently… You’re already performing at a top 10% frontend level in interviews. ♻️ Save this for revision and repost to help someone preparing for frontend interviews. 🚀 Follow Shubham Kumar Raj for more deep-dive JavaScript content #javascript #frontenddeveloper #codinginterview #webdevelopment #programming #learnjavascript #interviewprep #CareerGrowth #SowftwareEngineering #ReactJS
To view or add a comment, sign in
-
html-attributes-maintainability-accessibility-interview-q The Interview Trap: "I just add `role='button'` to this `<div>` and call it a day." 🛑 STOP. That's a recipe for technical debt and accessibility lawsuits. Here's the Senior-level breakdown: 1️⃣ The `Semantic Noise` Problem: Excessive `aria-*` attributes on non-interactive elements confuse `screen readers`. Native HTML elements like `<button>`, `<a>`, and `<input>` come with built-in accessibility trees. Don't override them unless absolutely necessary. 2️⃣ The `Maintainability` Nightmare: Inline `style` attributes and bloated `data-*` attributes make your codebase brittle. Refactoring becomes a `dom traversal` exercise instead of a simple CSS class update. It violates the `Separation of Concerns` principle. 3️⃣ The `ARIA` Misuse: The `First Rule of ARIA`: If you can use a native HTML element, DO IT. Misusing `role` attributes without proper `tabindex` or `keyboard` support creates `focus traps` and broken interactions. 4️⃣ The 2026 Standard: Modern frameworks encourage `component-driven` design, but the underlying HTML must remain clean. `Semantic HTML` is the only way to ensure `WCAG 2.2` compliance and future-proof your code against AI-driven parsing. Found this useful? Follow for more such interview questions and save post for your next prep session! #HTML,#WebDev,#Interviews,#CodingTips,#Accessibility
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Keep sharing