[{"data":1,"prerenderedAt":180},["ShallowReactive",2],{"term-e\u002Fexplicit-resource-management":3,"related-e\u002Fexplicit-resource-management":163},{"id":4,"title":5,"acronym":6,"body":7,"category":144,"description":145,"difficulty":146,"extension":147,"letter":148,"meta":149,"navigation":150,"path":151,"related":152,"seo":157,"sitemap":158,"stem":161,"subcategory":6,"__hash__":162},"terms\u002Fterms\u002Fe\u002Fexplicit-resource-management.md","Explicit Resource Management",null,{"type":8,"value":9,"toc":138},"minimark",[10,15,19,23,26,30,127,131,134],[11,12,14],"h2",{"id":13},"eli5-the-vibe-check","ELI5 - The Vibe Check",[16,17,18],"p",{},"Explicit Resource Management gives JavaScript a using keyword that automatically cleans things up when they go out of scope, like closing a file handle or an AbortController, without you writing a try\u002Ffinally every single time. It's the same idea as Python's with block or C#'s using statement, finally landing in JS.",[11,20,22],{"id":21},"real-talk","Real Talk",[16,24,25],{},"Explicit Resource Management is a TC39 feature, shipped in TypeScript 5.2+ and modern JS engines, that introduces using and await using declarations, which automatically call a resource's Symbol.dispose or Symbol.asyncDispose method when the enclosing block exits, even on early return or thrown error. It formalizes deterministic cleanup for things like database connections, file handles, and network resources.",[11,27,29],{"id":28},"show-me-the-code","Show Me The Code",[31,32,37],"pre",{"className":33,"code":34,"language":35,"meta":36,"style":36},"language-typescript shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","function readFile(path) {\n  using file = openFile(path); \u002F\u002F auto-closed at block end\n  return file.read();\n} \u002F\u002F file.close() called here automatically, even on throw\n","typescript","",[38,39,40,67,97,118],"code",{"__ignoreMap":36},[41,42,45,49,53,57,61,64],"span",{"class":43,"line":44},"line",1,[41,46,48],{"class":47},"spNyl","function",[41,50,52],{"class":51},"s2Zo4"," readFile",[41,54,56],{"class":55},"sMK4o","(",[41,58,60],{"class":59},"sHdIc","path",[41,62,63],{"class":55},")",[41,65,66],{"class":55}," {\n",[41,68,70,73,77,80,83,86,88,90,93],{"class":43,"line":69},2,[41,71,72],{"class":47},"  using",[41,74,76],{"class":75},"sTEyZ"," file",[41,78,79],{"class":55}," =",[41,81,82],{"class":51}," openFile",[41,84,56],{"class":85},"swJcz",[41,87,60],{"class":75},[41,89,63],{"class":85},[41,91,92],{"class":55},";",[41,94,96],{"class":95},"sHwdD"," \u002F\u002F auto-closed at block end\n",[41,98,100,104,106,109,112,115],{"class":43,"line":99},3,[41,101,103],{"class":102},"s7zQu","  return",[41,105,76],{"class":75},[41,107,108],{"class":55},".",[41,110,111],{"class":51},"read",[41,113,114],{"class":85},"()",[41,116,117],{"class":55},";\n",[41,119,121,124],{"class":43,"line":120},4,[41,122,123],{"class":55},"}",[41,125,126],{"class":95}," \u002F\u002F file.close() called here automatically, even on throw\n",[11,128,130],{"id":129},"when-youll-hear-this","When You'll Hear This",[16,132,133],{},"\"We swapped the try\u002Ffinally boilerplate for a using declaration and the cleanup is guaranteed either way.\" \u002F \"await using needs Symbol.asyncDispose implemented on the resource, plain Promises won't work.\"",[135,136,137],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":36,"searchDepth":69,"depth":69,"links":139},[140,141,142,143],{"id":13,"depth":69,"text":14},{"id":21,"depth":69,"text":22},{"id":28,"depth":69,"text":29},{"id":129,"depth":69,"text":130},"languages","Explicit Resource Management gives JavaScript a using keyword that automatically cleans things up when they go out of scope, like closing a file handle or...","advanced","md","e",{},true,"\u002Fterms\u002Fe\u002Fexplicit-resource-management",[153,154,155,156],"TypeScript","Try\u002FCatch","Closure","JavaScript",{"title":5,"description":145},{"changefreq":159,"priority":160},"weekly",0.7,"terms\u002Fe\u002Fexplicit-resource-management","E7caelvaDJXglTGYNDjdbXMFmiSnyQgiiP5CFRtZTy8",[164,168,172,176],{"title":155,"path":165,"acronym":6,"category":166,"difficulty":146,"description":167},"\u002Fterms\u002Fc\u002Fclosure","frontend","A closure is when a function remembers the variables from the scope it was created in, even after that scope is gone.",{"title":156,"path":169,"acronym":6,"category":166,"difficulty":170,"description":171},"\u002Fterms\u002Fj\u002Fjavascript","beginner","JavaScript is what makes websites actually DO stuff. HTML is the bones, CSS is the skin, and JavaScript is the muscles and brain.",{"title":154,"path":173,"acronym":6,"category":174,"difficulty":170,"description":175},"\u002Fterms\u002Ft\u002Ftry-catch","general","Try\u002Fcatch is your safety net. You put risky code in the 'try' box, and if it blows up, the 'catch' box catches the explosion and handles it gracefully inst...",{"title":153,"path":177,"acronym":6,"category":166,"difficulty":178,"description":179},"\u002Fterms\u002Ft\u002Ftypescript","intermediate","TypeScript is JavaScript with a strict parent watching over it.",1792528083496]