[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"content:legacy:page:\u002Finterviews\u002Fjavascript":3,"content:legacy:navigation":429,"content:legacy:surround:\u002Finterviews\u002Fjavascript":757},{"id":4,"title":5,"body":6,"description":416,"extension":417,"icon":418,"meta":419,"modifiedAt":420,"navigation":421,"path":422,"publishedAt":423,"seo":424,"sitemap":425,"stem":426,"updatedAt":427,"__hash__":428},"interviews\u002Finterviews\u002Fjavascript.md","JavaScript",{"type":7,"value":8,"toc":414},"minimark",[9,76,94,120,187,230,251,283,308,344,373,396],[10,11,12,36],"collapsible",{},[13,14,16],"template",{"v-slot:title":15},"",[17,18,19],"ol",{},[20,21,22,23,27,28,31,32,35],"li",{},"How do ",[24,25,26],"code",{},"var",", ",[24,29,30],{},"let",", and ",[24,33,34],{},"const"," differ?",[13,37,38,63],{"v-slot:content":15},[39,40,41,50,58],"ul",{},[20,42,43,45,46,49],{},[24,44,26],{}," is function-scoped, can be redeclared, and is initialized to ",[24,47,48],{},"undefined"," during hoisting.",[20,51,52,54,55,57],{},[24,53,30],{}," and ",[24,56,34],{}," are block-scoped and remain in the temporal dead zone until their declarations run.",[20,59,60,62],{},[24,61,34],{}," prevents reassignment of the binding, not mutation of the referenced object.",[64,65,66,67,69,70,72,73,75],"p",{},"Prefer ",[24,68,34],{}," by default, use ",[24,71,30],{}," when reassignment is intentional, and avoid ",[24,74,26],{}," in modern code.",[10,77,78,86],{},[13,79,80],{"v-slot:title":15},[17,81,83],{"start":82},2,[20,84,85],{},"Explain closures with a practical use case.",[13,87,88,91],{"v-slot:content":15},[64,89,90],{},"A closure is a function together with access to the lexical environment in which it was created, even after the outer function returns.",[64,92,93],{},"Closures are useful for factories, private state, memoization, and event handlers. They can also retain large objects longer than expected, so remove long-lived listeners and references when they are no longer needed.",[10,95,96,104],{},[13,97,98],{"v-slot:title":15},[17,99,101],{"start":100},3,[20,102,103],{},"What happens in the event loop when a promise and a timer are both ready?",[13,105,106,113],{"v-slot:content":15},[64,107,108,109,112],{},"After the current call stack finishes, JavaScript drains the microtask queue before taking the next task. Promise reactions and ",[24,110,111],{},"queueMicrotask"," callbacks are microtasks; timer callbacks are tasks.",[64,114,115,116,119],{},"Therefore, a resolved promise callback normally runs before a ",[24,117,118],{},"setTimeout(..., 0)"," callback. An endless chain of microtasks can starve rendering and other tasks.",[10,121,122,140],{},[13,123,124],{"v-slot:title":15},[17,125,127],{"start":126},4,[20,128,129,130,27,133,31,136,139],{},"What is the difference between ",[24,131,132],{},"==",[24,134,135],{},"===",[24,137,138],{},"Object.is","?",[13,141,142,178],{"v-slot:content":15},[39,143,144,149,162],{},[20,145,146,148],{},[24,147,132],{}," performs type coercion before comparison and has several surprising edge cases.",[20,150,151,153,154,157,158,161],{},[24,152,135],{}," compares without coercion; ",[24,155,156],{},"NaN"," is not equal to itself and ",[24,159,160],{},"-0 === 0"," is true.",[20,163,164,166,167,169,170,173,174,177],{},[24,165,138],{}," treats ",[24,168,156],{}," as equal to itself and distinguishes ",[24,171,172],{},"-0"," from ",[24,175,176],{},"0",".",[64,179,180,181,183,184,186],{},"Use ",[24,182,135],{}," for normal application comparisons and choose ",[24,185,138],{}," only when those numeric edge cases matter.",[10,188,189,201],{},[13,190,191],{"v-slot:title":15},[17,192,194],{"start":193},5,[20,195,196,197,200],{},"How does ",[24,198,199],{},"this"," work in regular functions versus arrow functions?",[13,202,203,227],{"v-slot:content":15},[64,204,205,206,208,209,212,213,216,217,216,220,223,224,226],{},"For a regular function, ",[24,207,199],{}," depends on how the function is called: as a method, with ",[24,210,211],{},"new",", through ",[24,214,215],{},"call","\u002F",[24,218,219],{},"apply",[24,221,222],{},"bind",", or as a plain function. Arrow functions do not create their own ",[24,225,199],{},"; they capture it lexically from the surrounding scope.",[64,228,229],{},"Arrow functions are useful for callbacks, but usually not for object methods that require a dynamic receiver.",[10,231,232,240],{},[13,233,234],{"v-slot:title":15},[17,235,237],{"start":236},6,[20,238,239],{},"What is prototypal inheritance?",[13,241,242,248],{"v-slot:content":15},[64,243,244,245,177],{},"Objects can delegate property lookup to another object through their internal prototype. If a property is not found on the object, lookup continues along the prototype chain until it reaches ",[24,246,247],{},"null",[64,249,250],{},"JavaScript classes are syntax over this model: instance methods live on the constructor's prototype and are shared by instances rather than copied onto each object.",[10,252,253,265],{},[13,254,255],{"v-slot:title":15},[17,256,258],{"start":257},7,[20,259,260,261,264],{},"When would you use ",[24,262,263],{},"Map"," instead of a plain object?",[13,266,267,276],{"v-slot:content":15},[64,268,180,269,271,272,275],{},[24,270,263],{}," when keys are not limited to strings and symbols, insertion order matters, frequent additions and removals are expected, or an explicit ",[24,273,274],{},"size"," and iterable API are helpful.",[64,277,278,279,282],{},"Use a plain object for JSON-like records with a known set of named fields. Use ",[24,280,281],{},"WeakMap"," for metadata keyed by objects when entries should not prevent garbage collection.",[10,284,285,293],{},[13,286,287],{"v-slot:title":15},[17,288,290],{"start":289},8,[20,291,292],{},"How do shallow and deep copies differ?",[13,294,295,302],{"v-slot:content":15},[64,296,297,298,301],{},"A shallow copy duplicates only the outer container, so nested objects remain shared. Object spread, ",[24,299,300],{},"Object.assign",", and array spread are shallow.",[64,303,304,307],{},[24,305,306],{},"structuredClone"," handles many built-in data types and circular references, but not functions or every host object. A domain-specific copy is often clearer when only selected fields need duplication.",[10,309,310,324],{},[13,311,312],{"v-slot:title":15},[17,313,315],{"start":314},9,[20,316,317,318,216,321,139],{},"How should errors be handled with ",[24,319,320],{},"async",[24,322,323],{},"await",[13,325,326,329],{"v-slot:content":15},[64,327,328],{},"Awaited rejections throw, so handle them at a layer that can add context, recover, translate the error, or report it. Avoid empty catches.",[64,330,331,332,335,336,339,340,343],{},"For independent operations, use ",[24,333,334],{},"Promise.all"," for fail-fast behavior or ",[24,337,338],{},"Promise.allSettled"," when every outcome matters. Preserve the original error as a cause when wrapping it, and use ",[24,341,342],{},"finally"," for cleanup.",[10,345,346,354],{},[13,347,348],{"v-slot:title":15},[17,349,351],{"start":350},10,[20,352,353],{},"What are ES modules, and how do they enable tree shaking?",[13,355,356,366],{"v-slot:content":15},[64,357,358,359,54,362,365],{},"ES modules use static ",[24,360,361],{},"import",[24,363,364],{},"export"," declarations. Their statically analyzable structure lets tooling identify bindings and potentially remove unused exports from production bundles.",[64,367,368,369,372],{},"Tree shaking is limited by side effects, dynamic access patterns, and package metadata. Dynamic ",[24,370,371],{},"import()"," creates an asynchronous module boundary and can split code by route or feature.",[10,374,375,383],{},[13,376,377],{"v-slot:title":15},[17,378,380],{"start":379},11,[20,381,382],{},"Debouncing and throttling solve what different problems?",[13,384,385,393],{"v-slot:content":15},[39,386,387,390],{},[20,388,389],{},"Debouncing waits until calls stop for a specified period, which suits search input or validation.",[20,391,392],{},"Throttling limits execution to at most once per interval, which suits scroll or pointer updates.",[64,394,395],{},"Both should define leading\u002Ftrailing behavior and expose cancellation when used by components with a lifecycle.",[10,397,398,406],{},[13,399,400],{"v-slot:title":15},[17,401,403],{"start":402},12,[20,404,405],{},"How would you investigate a memory leak in a browser application?",[13,407,408,411],{"v-slot:content":15},[64,409,410],{},"Reproduce a stable user flow, record heap snapshots before and after repeated runs, force garbage collection in development tools, and inspect objects that remain reachable.",[64,412,413],{},"Common causes include forgotten event listeners, timers, observers, detached DOM trees, unbounded caches, and closures retaining large state. Fix ownership and cleanup rather than manually nulling unrelated values.",{"title":15,"searchDepth":82,"depth":82,"links":415},[],"JavaScript interview questions about the runtime, asynchronous code, objects, modules, and performance.","md","logos:javascript",{},null,true,"\u002Finterviews\u002Fjavascript","2026-09-21",{"title":5,"description":416},{"loc":422,"lastmod":423},"interviews\u002Fjavascript","2026-09-21T22:49:35+07:00","plcbXe6pgN_rw8Ft9XIgZ-8OE_o_7596auNUhGQrQe4",[430,580,688,703],{"title":431,"icon":432,"path":433,"stem":434,"children":435,"page":446},"Posts","fluent-color:data-bar-vertical-ascending-24","\u002Fposts","posts",[436,447,465,491,501,514,524,534,544,570],{"title":437,"icon":438,"redirect":439,"path":440,"stem":441,"children":442,"page":446},"Database","material-icon-theme:database","\u002Fposts\u002Fdatabase\u002Freplication-strategy","\u002Fposts\u002Fdatabase","posts\u002Fdatabase",[443],{"title":444,"path":439,"stem":445,"icon":420},"Database Replication strategy in large systems","posts\u002Fdatabase\u002Freplication-strategy",false,{"title":448,"icon":449,"redirect":450,"path":451,"stem":452,"children":453,"page":446},"Docker","vscode-icons:file-type-docker2","\u002Fposts\u002Fdocker\u002Fdocker-commands","\u002Fposts\u002Fdocker","posts\u002Fdocker",[454,457,461],{"title":455,"path":450,"stem":456,"icon":420},"Docker commands essentials","posts\u002Fdocker\u002Fdocker-commands",{"title":458,"path":459,"stem":460,"icon":420},"Some useful Dockerfile templates","\u002Fposts\u002Fdocker\u002Fdockerfile-templates","posts\u002Fdocker\u002Fdockerfile-templates",{"title":462,"path":463,"stem":464,"icon":420},"Setup Docker environment on Windows","\u002Fposts\u002Fdocker\u002Fsetup-docker-on-window","posts\u002Fdocker\u002Fsetup-docker-on-window",{"title":466,"icon":467,"redirect":468,"path":469,"stem":470,"children":471,"page":446},"Git & GitHub","material-icon-theme:git","\u002Fposts\u002Fgit\u002Fbrightly-decorate-graph","\u002Fposts\u002Fgit","posts\u002Fgit",[472,475,479,483,487],{"title":473,"path":468,"stem":474,"icon":420},"Brightly decorate your GitHub Graph","posts\u002Fgit\u002Fbrightly-decorate-graph",{"title":476,"path":477,"stem":478,"icon":420},"Download a specific folder on GitHub repository","\u002Fposts\u002Fgit\u002Fdownload-specific-folder","posts\u002Fgit\u002Fdownload-specific-folder",{"title":480,"path":481,"stem":482,"icon":420},"Syncing Git Tags across to other repositories","\u002Fposts\u002Fgit\u002Fsyncing-tags-across-repositories","posts\u002Fgit\u002Fsyncing-tags-across-repositories",{"title":484,"path":485,"stem":486,"icon":420},"Unlocking GitHub Achievement badges","\u002Fposts\u002Fgit\u002Funlocking-achievement-badges","posts\u002Fgit\u002Funlocking-achievement-badges",{"title":488,"path":489,"stem":490,"icon":420},"Essential Git commands every developer should master","\u002Fposts\u002Fgit\u002Fuseful-commands-like-pro","posts\u002Fgit\u002Fuseful-commands-like-pro",{"title":492,"icon":493,"redirect":494,"path":495,"stem":496,"children":497,"page":446},"Golang","material-icon-theme:go","\u002Fposts\u002Fgolang\u002Foptimizing-performance-with-pgo","\u002Fposts\u002Fgolang","posts\u002Fgolang",[498],{"title":499,"path":494,"stem":500,"icon":420},"Optimizing Performance in Go Applications with PGO","posts\u002Fgolang\u002Foptimizing-performance-with-pgo",{"title":5,"icon":502,"redirect":503,"path":504,"stem":505,"children":506,"page":446},"vscode-icons:file-type-js","\u002Fposts\u002Fjavascript\u002F9-lines-of-tips","\u002Fposts\u002Fjavascript","posts\u002Fjavascript",[507,510],{"title":508,"path":503,"stem":509,"icon":420},"9 lines of JavaScript replace 50 lines of code","posts\u002Fjavascript\u002F9-lines-of-tips",{"title":511,"path":512,"stem":513,"icon":420},"Javascript Promises - Specific functions and use cases","\u002Fposts\u002Fjavascript\u002Fpromises-cheatsheet","posts\u002Fjavascript\u002Fpromises-cheatsheet",{"title":515,"icon":516,"redirect":517,"path":518,"stem":519,"children":520,"page":446},"Node","material-icon-theme:nodejs-alt","\u002Fposts\u002Fnodejs\u002Fevent-loop","\u002Fposts\u002Fnodejs","posts\u002Fnodejs",[521],{"title":522,"path":517,"stem":523,"icon":420},"Secret about Event Loop flow in Nodejs","posts\u002Fnodejs\u002Fevent-loop",{"title":525,"icon":526,"redirect":527,"path":528,"stem":529,"children":530,"page":446},"Nuxt","vscode-icons:file-type-nuxt","\u002Fposts\u002Fnuxt\u002Fenable-pwa-in-nuxt","\u002Fposts\u002Fnuxt","posts\u002Fnuxt",[531],{"title":532,"path":527,"stem":533,"icon":420},"Enable PWA and Service Worker in Nuxt","posts\u002Fnuxt\u002Fenable-pwa-in-nuxt",{"title":535,"icon":536,"redirect":537,"path":538,"stem":539,"children":540,"page":446},"Performance","emojione:rocket","\u002Fposts\u002Fperformance\u002Fbackground-image-injection-problem","\u002Fposts\u002Fperformance","posts\u002Fperformance",[541],{"title":542,"path":537,"stem":543,"icon":420},"Background-Image injection problem in UX","posts\u002Fperformance\u002Fbackground-image-injection-problem",{"title":545,"icon":546,"redirect":547,"path":548,"stem":549,"children":550,"page":446},"Tutorial","fluent-color:book-open-lightbulb-24","\u002Fposts\u002Ftutorial\u002Fclassification-and-functionality-of-the-servers","\u002Fposts\u002Ftutorial","posts\u002Ftutorial",[551,554,558,562,566],{"title":552,"path":547,"stem":553,"icon":420},"Classification and functionality of the servers","posts\u002Ftutorial\u002Fclassification-and-functionality-of-the-servers",{"title":555,"path":556,"stem":557,"icon":420},"What is the difference between localhost and 127.0.0.1?","\u002Fposts\u002Ftutorial\u002Fdifferent-between-localhost-and-127-0-0-1","posts\u002Ftutorial\u002Fdifferent-between-localhost-and-127-0-0-1",{"title":559,"path":560,"stem":561,"icon":420},"8 essential network protocols every programmer should know","\u002Fposts\u002Ftutorial\u002Fessential-network-protocols","posts\u002Ftutorial\u002Fessential-network-protocols",{"title":563,"path":564,"stem":565,"icon":420},"Pre rels in header link tag - SEO technique enhancement","\u002Fposts\u002Ftutorial\u002Fpre-rels-in-header-link-tag","posts\u002Ftutorial\u002Fpre-rels-in-header-link-tag",{"title":567,"path":568,"stem":569,"icon":420},"Better code with SOLID principles","\u002Fposts\u002Ftutorial\u002Fwhat-is-solid","posts\u002Ftutorial\u002Fwhat-is-solid",{"title":571,"icon":572,"redirect":573,"path":574,"stem":575,"children":576,"page":446},"UI\u002FUX","devicon:figma","\u002Fposts\u002Fuiux\u002Fcommon-button-mistake","\u002Fposts\u002Fuiux","posts\u002Fuiux",[577],{"title":578,"path":573,"stem":579,"icon":420},"Common Button Mistake in UI\u002FUX","posts\u002Fuiux\u002Fcommon-button-mistake",{"title":581,"icon":582,"path":583,"stem":584,"children":585,"page":446},"Cheatsheets","fluent-color:paw-16","\u002Fcheatsheets","cheatsheets",[586,591,596,599,604,607,612,616,621,626,631,636,641,646,650,654,659,664,668,673,678,683],{"title":587,"path":588,"stem":589,"icon":590},"Bash","\u002Fcheatsheets\u002Fbash","cheatsheets\u002Fbash","material-icon-theme:powershell",{"title":592,"path":593,"stem":594,"icon":595},"CSS","\u002Fcheatsheets\u002Fcss","cheatsheets\u002Fcss","vscode-icons:file-type-css2",{"title":448,"path":597,"stem":598,"icon":449},"\u002Fcheatsheets\u002Fdocker","cheatsheets\u002Fdocker",{"title":600,"path":601,"stem":602,"icon":603},"Git","\u002Fcheatsheets\u002Fgit","cheatsheets\u002Fgit","devicon:git",{"title":492,"path":605,"stem":606,"icon":493},"\u002Fcheatsheets\u002Fgo","cheatsheets\u002Fgo",{"title":608,"path":609,"stem":610,"icon":611},"HTML","\u002Fcheatsheets\u002Fhtml","cheatsheets\u002Fhtml","material-icon-theme:html",{"title":5,"path":613,"stem":614,"icon":615},"\u002Fcheatsheets\u002Fjavascript","cheatsheets\u002Fjavascript","material-icon-theme:javascript",{"title":617,"path":618,"stem":619,"icon":620},"Latex","\u002Fcheatsheets\u002Flatex","cheatsheets\u002Flatex","material-icon-theme:latexmk",{"title":622,"path":623,"stem":624,"icon":625},"Linux","\u002Fcheatsheets\u002Flinux","cheatsheets\u002Flinux","devicon:linux",{"title":627,"path":628,"stem":629,"icon":630},"Markdown","\u002Fcheatsheets\u002Fmarkdown","cheatsheets\u002Fmarkdown","material-icon-theme:markdown",{"title":632,"path":633,"stem":634,"icon":635},"Mongo","\u002Fcheatsheets\u002Fmongo","cheatsheets\u002Fmongo","devicon:mongodb",{"title":637,"path":638,"stem":639,"icon":640},"Nest","\u002Fcheatsheets\u002Fnest","cheatsheets\u002Fnest","material-icon-theme:nest",{"title":642,"path":643,"stem":644,"icon":645},"Next","\u002Fcheatsheets\u002Fnext","cheatsheets\u002Fnext","logos:nextjs-icon",{"title":515,"path":647,"stem":648,"icon":649},"\u002Fcheatsheets\u002Fnode","cheatsheets\u002Fnode","material-icon-theme:nodejs",{"title":525,"path":651,"stem":652,"icon":653},"\u002Fcheatsheets\u002Fnuxt","cheatsheets\u002Fnuxt","material-icon-theme:nuxt",{"title":655,"path":656,"stem":657,"icon":658},"React","\u002Fcheatsheets\u002Freact","cheatsheets\u002Freact","material-icon-theme:react",{"title":660,"path":661,"stem":662,"icon":663},"Redis","\u002Fcheatsheets\u002Fredis","cheatsheets\u002Fredis","vscode-icons:folder-type-redis-opened",{"title":665,"path":666,"stem":667,"icon":438},"SQL","\u002Fcheatsheets\u002Fsql","cheatsheets\u002Fsql",{"title":669,"path":670,"stem":671,"icon":672},"Typescript","\u002Fcheatsheets\u002Ftypescript","cheatsheets\u002Ftypescript","material-icon-theme:typescript",{"title":674,"path":675,"stem":676,"icon":677},"Vercel","\u002Fcheatsheets\u002Fvercel","cheatsheets\u002Fvercel","vscode-icons:file-type-light-vercel",{"title":679,"path":680,"stem":681,"icon":682},"Vue","\u002Fcheatsheets\u002Fvue","cheatsheets\u002Fvue","material-icon-theme:vue",{"title":684,"path":685,"stem":686,"icon":687},"Windows","\u002Fcheatsheets\u002Fwindow","cheatsheets\u002Fwindow","material-icon-theme:folder-windows",{"title":689,"icon":690,"path":691,"stem":692,"children":693,"page":446},"Prompts","fluent-color:bot-sparkle-24","\u002Fprompts","prompts",[694],{"title":695,"path":696,"stem":697,"children":698,"page":446},"Image Generation","\u002Fprompts\u002Fimage-generation","prompts\u002Fimage-generation",[699],{"title":700,"path":701,"stem":702,"icon":690},"Futuristic Cloud Workspace","\u002Fprompts\u002Fimage-generation\u002Ffuturistic-cloud-workspace","prompts\u002Fimage-generation\u002Ffuturistic-cloud-workspace",{"title":704,"icon":705,"path":706,"stem":707,"children":708,"page":446},"Interviews","lucide:messages-square","\u002Finterviews","interviews",[709,713,718,721,722,727,732,737,742,747,752],{"title":710,"path":711,"stem":712,"icon":705},"Behavioral Engineering","\u002Finterviews\u002Fbehavioral-engineering","interviews\u002Fbehavioral-engineering",{"title":714,"path":715,"stem":716,"icon":717},"DevOps and Cloud","\u002Finterviews\u002Fdevops-cloud","interviews\u002Fdevops-cloud","logos:docker-icon",{"title":608,"path":719,"stem":720,"icon":611},"\u002Finterviews\u002Fhtml","interviews\u002Fhtml",{"title":5,"path":422,"stem":426,"icon":418},{"title":723,"path":724,"stem":725,"icon":726},"Node.js and API Design","\u002Finterviews\u002Fnodejs-api","interviews\u002Fnodejs-api","logos:nodejs-icon",{"title":728,"path":729,"stem":730,"icon":731},"Software Testing","\u002Finterviews\u002Fsoftware-testing","interviews\u002Fsoftware-testing","lucide:flask-conical",{"title":733,"path":734,"stem":735,"icon":736},"SQL and Databases","\u002Finterviews\u002Fsql-databases","interviews\u002Fsql-databases","lucide:database",{"title":738,"path":739,"stem":740,"icon":741},"System Design","\u002Finterviews\u002Fsystem-design","interviews\u002Fsystem-design","lucide:network",{"title":743,"path":744,"stem":745,"icon":746},"TypeScript","\u002Finterviews\u002Ftypescript","interviews\u002Ftypescript","logos:typescript-icon",{"title":748,"path":749,"stem":750,"icon":751},"Vue and Nuxt","\u002Finterviews\u002Fvue-nuxt","interviews\u002Fvue-nuxt","logos:nuxt-icon",{"title":753,"path":754,"stem":755,"icon":756},"Web Security","\u002Finterviews\u002Fweb-security","interviews\u002Fweb-security","lucide:shield-check",[758,759],{"title":608,"path":719,"stem":720,"children":-1},{"title":723,"path":724,"stem":725,"children":-1}]