Menu
CoddyTech
Course

Luau for JavaScript Developers

Transfer JavaScript skills to general Luau: truth rules, typed signatures, runtime validation, table collections, relative modules and metatable objects. Build a stock ledger and port two source programs.

JavaScript and Luau side by side

The same program in JavaScript and in Luau, from the lessons of this course.

  1. Print and Comment

    JavaScript uses + and template literals; Luau uses .. and backtick interpolation with braces instead of dollar-braces. console.log is a host API, while print is the Luau output function.

    JavaScript
    1console.log("Hi" + ", Ada");
    Luau
    1local name = "Ada"2print(`Hi, {name}`)
  2. Missing Fields and Optionals

    An own JavaScript property can exist with value undefined. Assigning nil removes a Luau table key. Port property-presence checks deliberately instead of translating undefined to a stored nil field.

    JavaScript
    1const record = {x: undefined};2console.log("x" in record);
    Luau
    1local d = {x = nil}2print(d.x == nil)
  3. Inclusive Numeric Loops

    JavaScript for spells out initialization, condition and update. Luau numeric for includes its upper bound. Translate an exclusive JavaScript stop value to an inclusive Luau endpoint.

    JavaScript
    1let total = 0;2for (let i = 1; i < 4; i++) total += i;3console.log(total);
    Luau
    1local total = 02for i = 1, 3 do total = total + i end3print(total)
  4. Functions and Returns

    JavaScript functions accept omitted arguments as undefined; Luau receives nil. Both can pass functions as values. Luau additionally accepts erased signature annotations, but Run will not statically reject a wrong argument type.

    JavaScript
    1function twice(x) { return x * 2; }2console.log(twice(4));
    Luau
    1local function twice(x: number): number return x * 2 end2print(twice(4))
  5. Lists as Dense Tables

    JavaScript arrays combine indexed storage, methods and a length property. Luau uses ordinary tables plus library operations. Keep sequence keys dense and do not copy zero-based array offsets.

    JavaScript
    1const a=["a","b","c"];2a.splice(1,1);3console.log(a.join(","));
    Luau
    1local a = {"a", "b", "c"}2table.remove(a, 2)3print(table.concat(a, ","))
  6. Sorting and Comparators

    JavaScript Array.sort comparators return a negative, zero or positive number. Luau table.sort comparators return booleans. Returning a numeric difference in Luau makes even zero truthy and breaks the ordering contract.

    JavaScript
    1const a=[3,1,2];2a.sort((x,y)=>x-y);3console.log(a[0]);
    Luau
    1local a={3,1,2}2table.sort(a)3print(a[1])

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Final Source Ports

2 lessons

More courses for JavaScript developers

Learn Luau from another language

Frequently asked questions

Who is Luau for JavaScript Developers for?

For people who already write JavaScript and want to learn Luau. Each lesson starts from JavaScript you know and shows how Luau does the same thing, so you skip the beginner basics.

Do I need to know Luau already?

No. The course starts with your first Luau program. You need JavaScript basics: variables, conditions, loops, functions and collections.

How many lessons does Luau for JavaScript Developers have?

Luau for JavaScript Developers contains 48 interactive lessons you can complete at your own pace.

What does Luau for JavaScript Developers cover?

The course is organized into chapters covering: First Luau Programs, Values and Decisions, Iteration and Flow, Functions and Closures, and more.

Is Luau for JavaScript Developers free?

Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.

Coddy programming languages illustration

Start Luau for JavaScript Developers for free

Get started