GDScript for JavaScript Developers
Move from JavaScript to Godot 4 GDScript: static and dynamic types, collection ownership, classes, signals and explicit failures. Build a connected stock depot and port two JavaScript programs across 48 multi-file lessons.
JavaScript and GDScript side by side
The same program in JavaScript and in GDScript, from the lessons of this course.
Text and Comments
JavaScript console.log formats separate primitive arguments with spaces in Node.js. GDScript print concatenates arguments without inserting that separator, so add literal spacing or use a format string. GDScript uses indentation and colon-delimited blocks…
JavaScript1console.log('tag',7);2console.log('# data');GDScript1extends Node2 3func _ready() -> void:4 print("tag", 7)5 print("# data")Branches and Values
GDScript if, elif and else use indentation and colons instead of JavaScript braces and else if. JavaScript writes a conditional expression as condition ? first : second; GDScript writes first if condition else second. Only the chosen result is evaluated. An…
JavaScript1const n=-2;2console.log(n<0?'west':'east');GDScript1extends Node2 3func _ready() -> void:4 var n: int = -25 print("west" if n < 0 else "east")Array Operations
JavaScript arrays and GDScript Arrays are growable reference containers. JavaScript push and pop correspond broadly to append and pop_back. A GDScript negative index addresses elements from the end, whereas JavaScript bracket access with -1 is a property…
JavaScript1const items=[3];2items.push(8);3console.log(items.pop(),items.length);GDScript1extends Node2 3func _ready() -> void:4 var items: Array = [3]5 items.append(8)6 var removed = items.pop_back()7 print("%d %d" % [removed,items.size()])String Operations
JavaScript strings are immutable; GDScript strings have value semantics with copy-on-write storage. Replacing or trimming returns a string rather than mutating all aliases like an Array. JavaScript replace with a plain string replaces only the first…
JavaScript1const s='a-b-a';2const t=s.replaceAll('-','/');3console.log(s,t);GDScript1extends Node2 3func _ready() -> void:4 var s: String = "a-b-a"5 var t: String = s.replace("-","/")6 print(s," ",t)Scripts as Classes
JavaScript class declarations create constructor/prototype relationships. A GDScript file itself defines a class; class_name registers a global script type and extends selects its base. Use RefCounted for data helpers that do not need a scene-tree lifetime…
JavaScript1export class Token { constructor(){this.text='blue';} }GDScript1class_name DemoToken2extends RefCounted3var text: String = "blue"Inheritance and Super
JavaScript class extends and GDScript extends each select one superclass. GDScript can name a registered script class as the base, and an override can call the inherited implementation through super. A subclass remains compatible with its base type, but…
JavaScript1export class Base { label(){return 'base';} }GDScript1class_name DemoBase2extends RefCounted3func label() -> String:4 return "base"
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsScripts and Scalar Values
6 lessonsFlow and Functions
6 lessonsCollection Ownership
6 lessonsText and Callable Values
3 lessonsObjects and State
5 lessonsObject Relationships
5 lessonsEvents and Failure
5 lessonsBoundaries and Lifetimes
6 lessonsConnected Stock Depot
Project4 lessonsFinal Ports
2 lessonsFrequently asked questions
Who is GDScript for JavaScript Developers for?
For people who already write JavaScript and want to learn GDScript. Each lesson starts from JavaScript you know and shows how GDScript does the same thing, so you skip the beginner basics.
Do I need to know GDScript already?
No. The course starts with your first GDScript program. You need JavaScript basics: variables, conditions, loops, functions and collections.
How many lessons does GDScript for JavaScript Developers have?
GDScript for JavaScript Developers contains 48 interactive lessons you can complete at your own pace.
What does GDScript for JavaScript Developers cover?
The course is organized into chapters covering: Scripts and Scalar Values, Flow and Functions, Collection Ownership, Text and Callable Values, and more.
Is GDScript 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.