JavaScript for PHP Developers
Transfer PHP experience to JavaScript: values, control flow, functions, collections, ES modules, errors, and objects. Build a tested order processor with reusable modules.
PHP and JavaScript side by side
The same program in PHP and in JavaScript, from the lessons of this course.
Strings and Templates
PHP interpolates variables in double-quoted strings; JavaScript interpolates expressions only in backtick template literals. PHP uses a dot for concatenation, while JavaScript plus can add numbers or concatenate text. console.log adds a newline, unlike echo…
PHP1<?php2$name="Ada";3echo "Hello, {$name}!", "4";JavaScript1const name = "Ada";2console.log(`Hello, ${name}!`);Strict Equality
Both languages offer strict equality without string-number coercion. PHP additionally distinguishes int and float types, while JavaScript uses Number for both. JavaScript object equality with === is identity; use an explicit method when comparing fields.…
PHP1<?php2echo var_export(3 === "3", true), "3";JavaScript1console.log(3 === "3");Arrays and Mutation
PHP arrays are ordered maps combining list and dictionary roles. JavaScript arrays are indexed objects; use Map for data-driven keys. push grows an array and returns its length. Negative bracket indexes do not count backward; at(-1) does.
PHP1<?php2$items=[2];3$items[]=3;4echo count($items), "5";JavaScript1const items = [2];2items.push(3);3console.log(items.length);While and Early Exit
while, break, and continue have familiar meanings, but JavaScript break does not take PHP numeric nesting levels. Use explicit loop conditions and advance on every continuing path. A sentinel should stop the scan before later values are processed.
PHP1<?php2$n=3;3while($n>1) $n--;4echo $n, "5";JavaScript1let n = 3;2while (n > 1) n -= 1;3console.log(n);Functions and Returns
PHP and JavaScript both support standalone functions, but JavaScript does not enforce declared parameter types or required argument counts in the same way. Missing arguments and missing returns produce undefined. Functions are values, so export a helper…
PHP1<?php2function twice($n) { return $n*2; }3echo twice(4), "4";JavaScript1function twice(n) { return n * 2; }2console.log(twice(4));JSON and Input Boundaries
PHP json_decode can return associative arrays when its second argument is true. JavaScript JSON.parse returns ordinary arrays and objects, not instances of application classes. Malformed JSON throws in JavaScript; PHP can opt into JSON_THROW_ON_ERROR. Keep…
PHP1<?php2$values=json_decode("[2,3]",true,512,JSON_THROW_ON_ERROR);3echo $values[1], "4";JavaScript1console.log(JSON.parse("[2,3]")[1]);
Syllabus
10 chapters48 lessons1 project48 challenges99 quiz questionsFirst JavaScript
6 lessonsDecisions and Flow
5 lessonsCollections
5 lessonsIteration Pipelines
5 lessonsFunctions
5 lessonsErrors and Modules
5 lessonsObjects and Classes
6 lessonsComposition and Dispatch
5 lessonsProject: Order Processor
4 lessonsFinal Challenges
2 lessonsFrequently asked questions
Who is JavaScript for PHP Developers for?
For people who already write PHP and want to learn JavaScript. Each lesson starts from PHP 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 PHP basics: variables, conditions, loops, functions and collections.
How many lessons does JavaScript for PHP Developers have?
JavaScript for PHP Developers contains 48 interactive lessons you can complete at your own pace.
What does JavaScript for PHP Developers cover?
The course is organized into chapters covering: First JavaScript, Decisions and Flow, Collections, Iteration Pipelines, and more.
Is JavaScript for PHP Developers free?
Yes. Every course on Coddy is free to start. You can complete lessons in your browser without any downloads or signup.