Menu
CoddyTech
Course

JavaScript for TypeScript Developers

Transfer TypeScript experience to JavaScript: values, control flow, functions, collections, ES modules, errors, and objects. Build a tested order processor with reusable modules.

TypeScript and JavaScript side by side

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

  1. Numbers and Conversion

    TypeScript number is already JavaScript binary floating point. Removing an annotation changes no arithmetic. Neither language makes division integral because both operands look like integers. Validate safe-integer bounds at external boundaries; this task…

    TypeScript
    1const value: number = -7 / 2;2console.log(Math.floor(value));
    JavaScript
    1console.log(Math.floor(-7 / 2));
  2. Strict Equality

    TypeScript warns about some impossible comparisons, but JavaScript executes the same strict-equality operator without a type checker. Use unknown at data boundaries and narrow it. Strict equality never converts a numeric string into a number.

    TypeScript
    1const equal = (a: unknown,b: unknown): boolean => a === b;2console.log(equal(3,"3"));
    JavaScript
    1console.log(3 === "3");
  3. Map and Set

    Generic parameters such as Map and Set are erased. The same Map APIs work in JavaScript, but set accepts a value of any type unless your code rejects it. Prefer Map to object properties when user-provided strings are keys.

    TypeScript
    1const values: Set<number> = new Set([2,2,3]);2console.log(values.size);
    JavaScript
    1console.log(new Set([2,2,3]).size);
  4. Defaults and Options

    Optional parameter annotations do not install runtime defaults. A default expression runs only for undefined, never null. An options interface disappears in JavaScript, so keep destructuring defaults and add validation if options arrive from untrusted input.

    TypeScript
    1function label(name: string = "guest"): string { return name; }2console.log(label());
    JavaScript
    1function label(name="guest") { return name; }2console.log(label());
  5. Throw and Catch

    A typed function signature does not describe thrown values. TypeScript catch variables may be unknown, which encourages instanceof checks; JavaScript needs those same runtime checks. Throw Error objects and rethrow failures that your catch does not understand.

    TypeScript
    1try { throw new RangeError("bad"); }2catch (error: unknown) { if (error instanceof Error) console.log(error.message); else throw error; }
    JavaScript
    1try { throw new RangeError("bad"); }2catch (error) { console.log(error.message); }
  6. Methods and Receiver Binding

    TypeScript this-parameter annotations can catch unbound calls, but they do not bind a function at runtime. Extracting a JavaScript method loses its receiver just as emitted TypeScript does. Use bind or an arrow wrapper before passing a method as a callback.

    TypeScript
    1class Counter { n: number=0; step(): number { return ++this.n; } }2const c=new Counter();3const f: () => number=c.step.bind(c);4console.log(f());
    JavaScript
    1class Counter { constructor() { this.n=0; } step() { return ++this.n; } }2const c=new Counter();3const f=c.step.bind(c);4console.log(f());

Syllabus

9 chapters28 lessons1 project28 challenges48 quiz questions

More courses for TypeScript developers

Learn JavaScript from another language

Frequently asked questions

Who is JavaScript for TypeScript Developers for?

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

How many lessons does JavaScript for TypeScript Developers have?

JavaScript for TypeScript Developers contains 28 interactive lessons you can complete at your own pace.

What does JavaScript for TypeScript Developers cover?

The course is organized into chapters covering: First JavaScript, Decisions and Flow, Collections, Functions, and more.

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

Get started