[{"data":1,"prerenderedAt":584},["ShallowReactive",2],{"page-\u002Flua":3},{"id":4,"title":5,"body":6,"description":16,"extension":577,"meta":578,"navigation":579,"path":580,"seo":581,"stem":582,"__hash__":583},"content\u002Flua\u002Findex.md","Lua: Zero to Hero",{"type":7,"value":8,"toc":564},"minimark",[9,13,17,22,55,59,62,66,71,206,210,307,311,393,397],[10,11,5],"h1",{"id":12},"lua-zero-to-hero",[14,15,16],"p",{},"A complete quiz-based curriculum covering Lua from first principles to expert-level, production-grade knowledge. Lua's minimalism is deceptive — nearly everything (objects, modules, namespaces) is built from one primitive, the table, and this track is sequenced around the handful of mechanisms (metatables, closures, coroutines) that make that possible.",[18,19,21],"h2",{"id":20},"how-to-use-this-quiz-track","How to Use This Quiz Track",[23,24,25,29,32,40,52],"ul",{},[26,27,28],"li",{},"Work through the parts in order; Part 2 onward assumes comfort with tables and closures from Part 1.",[26,30,31],{},"Each quiz has 20 multiple-choice questions, ordered from basic recall to edge cases to best-practice judgment calls.",[26,33,34,35,39],{},"Click ",[36,37,38],"strong",{},"Show Answer"," only after committing to a choice — the explanations cover the underlying mechanism (metamethods, upvalue sharing, coroutine state machines), not just the right letter.",[26,41,42,43,47,48,51],{},"Expect classic Lua \"wat\" moments — 1-based indexing, the ",[44,45,46],"code",{},"#"," operator on tables with holes, and ",[44,49,50],{},".."," string coercion — turned into quiz questions.",[26,53,54],{},"Questions target Lua 5.4 (the current reference implementation) and call out version differences (5.1\u002F5.2\u002F5.3, LuaJIT) where they matter in practice.",[18,56,58],{"id":57},"prerequisites","Prerequisites",[14,60,61],{},"None for Part 1, though familiarity with any dynamically-typed scripting language helps the table\u002Fclosure model click faster.",[18,63,65],{"id":64},"curriculum","Curriculum",[67,68,70],"h3",{"id":69},"part-1-foundations","Part 1 — Foundations",[72,73,74,89],"table",{},[75,76,77],"thead",{},[78,79,80,83,86],"tr",{},[81,82,46],"th",{},[81,84,85],{},"Topic",[81,87,88],{},"Why It Matters",[90,91,92,115,133,150,175,189],"tbody",{},[78,93,94,98,105],{},[95,96,97],"td",{},"01",[95,99,100],{},[101,102,104],"a",{"href":103},"\u002Flua\u002F01-introduction-and-setup","Introduction & Setup",[95,106,107,110,111,114],{},[44,108,109],{},"lua"," vs ",[44,112,113],{},"luajit",", embedding vs standalone, and version fragmentation (5.1–5.4) shape which features and libraries are actually available.",[78,116,117,120,126],{},[95,118,119],{},"02",[95,121,122],{},[101,123,125],{"href":124},"\u002Flua\u002F02-variables-and-data-types","Variables & Data Types",[95,127,128,129,132],{},"Globals-by-default, ",[44,130,131],{},"nil",", and the integer\u002Ffloat subtype split (5.3+) are frequent sources of subtle bugs.",[78,134,135,138,144],{},[95,136,137],{},"03",[95,139,140],{},[101,141,143],{"href":142},"\u002Flua\u002F03-operators-and-expressions","Operators & Expressions",[95,145,146,147,149],{},"String-to-number coercion via arithmetic operators and ",[44,148,50],{}," concatenation are classic gotcha territory.",[78,151,152,155,161],{},[95,153,154],{},"04",[95,156,157],{},[101,158,160],{"href":159},"\u002Flua\u002F04-control-flow","Control Flow",[95,162,163,166,167,170,171,174],{},[44,164,165],{},"repeat...until","'s scoping quirk and the absence of ",[44,168,169],{},"break","-with-label (only ",[44,172,173],{},"goto",") surprise newcomers.",[78,176,177,180,186],{},[95,178,179],{},"05",[95,181,182],{},[101,183,185],{"href":184},"\u002Flua\u002F05-strings-and-patterns","Strings & Patterns",[95,187,188],{},"Lua patterns are not regex — the differences trip up anyone assuming PCRE-style syntax.",[78,190,191,194,200],{},[95,192,193],{},"06",[95,195,196],{},[101,197,199],{"href":198},"\u002Flua\u002F06-tables","Tables",[95,201,202,203,205],{},"The array\u002Fhash duality and the famously undefined ",[44,204,46],{}," operator on tables with holes are the single biggest source of Lua bugs.",[67,207,209],{"id":208},"part-2-functions-scope","Part 2 — Functions & Scope",[72,211,212,222],{},[75,213,214],{},[78,215,216,218,220],{},[81,217,46],{},[81,219,85],{},[81,221,88],{},[90,223,224,242,260,281],{},[78,225,226,229,235],{},[95,227,228],{},"07",[95,230,231],{},[101,232,234],{"href":233},"\u002Flua\u002F07-functions","Functions",[95,236,237,238,241],{},"Multiple return values and varargs (",[44,239,240],{},"...",") are used pervasively and behave differently from most mainstream languages.",[78,243,244,247,253],{},[95,245,246],{},"08",[95,248,249],{},[101,250,252],{"href":251},"\u002Flua\u002F08-closures-and-upvalues","Closures & Upvalues",[95,254,255,256,259],{},"Shared upvalues across loop iterations are Lua's version of the classic JS ",[44,257,258],{},"var","-in-a-loop bug.",[78,261,262,265,271],{},[95,263,264],{},"09",[95,266,267],{},[101,268,270],{"href":269},"\u002Flua\u002F09-metatables-and-metamethods","Metatables & Metamethods",[95,272,273,276,277,280],{},[44,274,275],{},"__index","\u002F",[44,278,279],{},"__newindex"," and operator metamethods are how Lua achieves everything from OOP to operator overloading.",[78,282,283,286,292],{},[95,284,285],{},"10",[95,287,288],{},[101,289,291],{"href":290},"\u002Flua\u002F10-oop-with-tables-and-metatables","OOP with Tables & Metatables",[95,293,294,295,298,299,302,303,306],{},"Colon-call sugar (",[44,296,297],{},"obj:method()",") hides an implicit ",[44,300,301],{},"self"," that's a frequent source of ",[44,304,305],{},"attempt to call a nil value"," errors.",[67,308,310],{"id":309},"part-3-control-errors","Part 3 — Control & Errors",[72,312,313,323],{},[75,314,315],{},[78,316,317,319,321],{},[81,318,46],{},[81,320,85],{},[81,322,88],{},[90,324,325,352,372],{},[78,326,327,330,336],{},[95,328,329],{},"11",[95,331,332],{},[101,333,335],{"href":334},"\u002Flua\u002F11-error-handling","Error Handling",[95,337,338,276,341,344,345,276,348,351],{},[44,339,340],{},"pcall",[44,342,343],{},"xpcall"," and non-string error objects are Lua's whole error model — there's no ",[44,346,347],{},"try",[44,349,350],{},"catch",".",[78,353,354,357,363],{},[95,355,356],{},"12",[95,358,359],{},[101,360,362],{"href":361},"\u002Flua\u002F12-coroutines","Coroutines",[95,364,365,276,368,371],{},[44,366,367],{},"resume",[44,369,370],{},"yield"," state machines power generators, cooperative schedulers, and game-engine update loops.",[78,373,374,377,383],{},[95,375,376],{},"13",[95,378,379],{},[101,380,382],{"href":381},"\u002Flua\u002F13-modules-and-require","Modules & require",[95,384,385,388,389,392],{},[44,386,387],{},"require"," caching and ",[44,390,391],{},"package.path"," resolution order are essential for structuring any non-trivial project.",[67,394,396],{"id":395},"part-4-advanced-systems","Part 4 — Advanced & Systems",[72,398,399,409],{},[75,400,401],{},[78,402,403,405,407],{},[81,404,46],{},[81,406,85],{},[81,408,88],{},[90,410,411,425,439,465,490,504,526,550],{},[78,412,413,416,422],{},[95,414,415],{},"14",[95,417,418],{},[101,419,421],{"href":420},"\u002Flua\u002F14-garbage-collection","Garbage Collection",[95,423,424],{},"Incremental vs. generational GC (5.4) and weak tables matter for anyone building caches or long-running processes.",[78,426,427,430,436],{},[95,428,429],{},"15",[95,431,432],{},[101,433,435],{"href":434},"\u002Flua\u002F15-the-c-api-and-ffi","The C API & FFI",[95,437,438],{},"Lua's defining use case is embedding — the stack-based C API and LuaJIT's FFI are how host applications actually integrate it.",[78,440,441,444,450],{},[95,442,443],{},"16",[95,445,446],{},[101,447,449],{"href":448},"\u002Flua\u002F16-advanced-metaprogramming","Advanced Metaprogramming",[95,451,452,455,456,459,460,276,462,464],{},[44,453,454],{},"__call",", ",[44,457,458],{},"__tostring",", and proxy tables via ",[44,461,275],{},[44,463,279],{}," enable sandboxing and DSL-style APIs.",[78,466,467,470,476],{},[95,468,469],{},"17",[95,471,472],{},[101,473,475],{"href":474},"\u002Flua\u002F17-standard-library-deep-dive","Standard Library Deep Dive",[95,477,478,481,482,485,486,489],{},[44,479,480],{},"table.sort"," stability, ",[44,483,484],{},"os.time"," granularity, and ",[44,487,488],{},"io"," buffering behavior matter in real scripts.",[78,491,492,495,501],{},[95,493,494],{},"18",[95,496,497],{},[101,498,500],{"href":499},"\u002Flua\u002F18-performance-and-luajit","Performance & LuaJIT",[95,502,503],{},"JIT trace compilation, deoptimization triggers, and table pre-sizing are where Lua performance work actually happens.",[78,505,506,509,515],{},[95,507,508],{},"19",[95,510,511],{},[101,512,514],{"href":513},"\u002Flua\u002F19-testing","Testing",[95,516,517,518,521,522,525],{},"Frameworks like ",[44,519,520],{},"busted"," and ",[44,523,524],{},"luaunit",", plus common assertion\u002Fmocking patterns, determine test suite trustworthiness.",[78,527,528,531,537],{},[95,529,530],{},"20",[95,532,533],{},[101,534,536],{"href":535},"\u002Flua\u002F20-security","Security",[95,538,539,276,542,545,546,549],{},[44,540,541],{},"load",[44,543,544],{},"loadstring"," on untrusted input and unsandboxed ",[44,547,548],{},"os.execute"," are the most common Lua vulnerabilities (notably in game modding and CDN edge scripts).",[78,551,552,555,561],{},[95,553,554],{},"21",[95,556,557],{},[101,558,560],{"href":559},"\u002Flua\u002F21-exercises-and-projects","Exercises & Projects (Capstone)",[95,562,563],{},"A mixed-review capstone spanning metatables, coroutines, closures, and error handling.",{"title":565,"searchDepth":566,"depth":566,"links":567},"",2,[568,569,570],{"id":20,"depth":566,"text":21},{"id":57,"depth":566,"text":58},{"id":64,"depth":566,"text":65,"children":571},[572,574,575,576],{"id":69,"depth":573,"text":70},3,{"id":208,"depth":573,"text":209},{"id":309,"depth":573,"text":310},{"id":395,"depth":573,"text":396},"md",{},true,"\u002Flua",{"title":5,"description":16},"lua\u002Findex","L-VlIQsKSs48TvQak4xkyfYYvLSlSo80OBAj9zwY8r8",1787335397337]