JavaScript for Lua Developers
Move from Lua tables and metatables to JavaScript arrays, Map, classes, and ES modules. Compare truthiness, indexing, multiple returns, closures, receivers, and errors, then build an order processor.
Lua and JavaScript side by side
The same program in Lua and in JavaScript, from the lessons of this course.
Concatenation to Templates
Lua concatenates text with double dots and commonly formats values with string.format. JavaScript uses plus for string concatenation and backtick template literals for interpolation. Single and double quotes do not interpolate dollar-brace expressions.…
Lua1local name = "Ada"2print("Hello, " .. name .. "!")JavaScript1const name = "Ada";2console.log(`Hello, ${name}!`);Equality and Coercion
Lua number and string equality does not equate numeric text with a number. JavaScript strict equality likewise avoids coercion, while loose equality can coerce them. Ordinary Lua tables and JavaScript objects both compare by identity unless explicit value…
Lua1print(3 == "3")2local a, b = {1}, {1}3print(a == b)JavaScript1console.log(3 === "3");Sequence Indexes and push
Lua table sequences conventionally start at one; JavaScript arrays start at zero. Lua table.insert appends to a sequence, while JavaScript push appends and returns the new length. A JavaScript negative bracket index is a property lookup, not a count from the…
Lua1local items = {2}2table.insert(items, 3)3print(#items)4print(items[1])JavaScript1const items = [2];2items.push(3);3console.log(items.length);while, break, and continue
Lua and JavaScript while loops reevaluate a condition before each iteration. Standard Lua has no continue keyword; JavaScript continue skips the rest of the current iteration. Break exits the innermost loop in both. Update progress variables on every path…
Lua1local n = 32while n > 1 do n = n - 1 end3print(n)JavaScript1let n = 3;2while (n > 1) n -= 1;3console.log(n);Functions and Return Counts
Lua functions can return multiple results, adjusted by their receiving context. JavaScript functions return one value; use an array or object to package several results. Both ordinary function bodies need explicit return for a useful value. JavaScript omitted…
Lua1local function twice(n)2 return n * 23end4print(twice(4))JavaScript1function twice(n) { return n * 2; }2console.log(twice(4));JSON Without Evaluation
Lua has no standard built-in JSON parser; programs normally use a vetted library or a narrowly specified adapter. JavaScript has JSON.parse and JSON.stringify. Parsing data must not be replaced with evaluating source code. The Lua snippet only extracts the…
Lua1local fixture = "[2,3]"2local second = fixture:match("^%[%d+,(%d+)%]$")3print(tonumber(second))JavaScript1console.log(JSON.parse("[2,3]")[1]);
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFrom Lua to JavaScript
6 lessonsDecisions and Flow
5 lessonsTables to Arrays and Maps
5 lessonsIteration Pipelines
5 lessonsFunctions and Closures
5 lessonsErrors and ES Modules
5 lessonsMetatables to Classes
6 lessonsComposition and Dispatch
5 lessonsProject: Order Processor
4 lessonsApply Your Lua Experience
2 lessonsFrequently asked questions
Who is JavaScript for Lua Developers for?
For people who already write Lua and want to learn JavaScript. Each lesson starts from Lua you know and shows how JavaScript does the same thing, so you skip the beginner basics.
Do I need to know JavaScript already?
No. The course starts with your first JavaScript program. You need Lua basics: variables, conditions, loops, functions and collections.
How many lessons does JavaScript for Lua Developers have?
JavaScript for Lua Developers contains 48 interactive lessons you can complete at your own pace.
What does JavaScript for Lua Developers cover?
The course is organized into chapters covering: From Lua to JavaScript, Decisions and Flow, Tables to Arrays and Maps, Iteration Pipelines, and more.
Is JavaScript for Lua Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.