Menu
CoddyTech
Course

JavaScript for Ruby Developers

Use Ruby experience to learn JavaScript: compare truthiness, Enumerable pipelines, Hash and Map, blocks and closures, method receivers, modules, and classes. Build a four-step order processor.

Ruby and JavaScript side by side

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

  1. Interpolation and Templates

    Ruby double-quoted strings interpolate with hash-braces; JavaScript interpolation uses backtick template literals and dollar-braces. JavaScript single and double quotes both create ordinary strings without interpolation. console.log prints a newline; Ruby…

    Ruby
    1name = "Ada"2puts "Hello, #{name}!"
    JavaScript
    1const name = "Ada";2console.log(`Hello, ${name}!`);
  2. Equality Without Coercion

    Ruby equality can be customized through ==, and arrays compare their contents. JavaScript strict equality avoids coercion but compares objects and arrays by identity. Use an explicit field or element comparison for value equality. JavaScript loose equality…

    Ruby
    1puts(3 == "3")2puts([1] == [1])
    JavaScript
    1console.log(3 === "3");
  3. Array Mutation and Last Items

    Ruby and JavaScript arrays are mutable and zero-indexed, but their APIs differ. Ruby push returns the array; JavaScript push returns its new length. Ruby negative indexing counts from the end, while JavaScript bracket lookup at negative one asks for a…

    Ruby
    1items = [2]2result = items.push(3)3puts result.equal?(items)4puts items[-1]
    JavaScript
    1const items = [2];2items.push(3);3console.log(items.length);
  4. while, next, and continue

    Ruby while and JavaScript while both repeat while their condition is true under each language's truth rules. Ruby next corresponds to JavaScript continue; break leaves the loop. JavaScript increments are available, but explicit updates often make a port…

    Ruby
    1n = 32while n > 13  n -= 14end5puts n
    JavaScript
    1let n = 3;2while (n > 1) n -= 1;3console.log(n);
  5. Methods and Explicit Returns

    Ruby methods normally return their final expression. JavaScript ordinary functions require return to provide a value; otherwise they produce undefined. Function declarations use parentheses and braces. JavaScript often tolerates extra arguments and gives…

    Ruby
    1def twice(n)2  n * 23end4puts twice(4)
    JavaScript
    1function twice(n) { return n * 2; }2console.log(twice(4));
  6. JSON at the Boundary

    Ruby JSON.parse requires its library and returns Ruby arrays, hashes, and primitives. JavaScript JSON.parse is built in and produces JavaScript values. JSON.stringify performs the inverse direction, but JSON cannot represent undefined, functions, or arbitrary…

    Ruby
    1require "json"2puts JSON.parse("[2,3]")[1]
    JavaScript
    1console.log(JSON.parse("[2,3]")[1]);

Syllabus

10 chapters48 lessons1 project48 challenges99 quiz questions

Apply Your Ruby Experience

2 lessons

More courses for Ruby developers

Learn JavaScript from another language

Frequently asked questions

Who is JavaScript for Ruby Developers for?

For people who already write Ruby and want to learn JavaScript. Each lesson starts from Ruby 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 Ruby basics: variables, conditions, loops, functions and collections.

How many lessons does JavaScript for Ruby Developers have?

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

What does JavaScript for Ruby Developers cover?

The course is organized into chapters covering: From Ruby to JavaScript, Decisions and Flow, Arrays, Hashes, and Maps, Enumerable to Array Pipelines, and more.

Is JavaScript for Ruby 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 JavaScript for Ruby Developers for free

Get started