As I dive deeper into React and AI-assisted development, I’ve realized something uncomfortable - my JavaScript fundamentals weren’t as solid as I thought. In this episode Matt and Mike revisit ES6 and modern JavaScript concepts like let vs var, const and mutability, arrow functions, this binding, destructuring, and more. We also explore how frameworks and AI tools can add layers of abstraction that quietly distance us from core fundamentals. If you’re working with React, Svelte, or modern tooling, this episode is a reminder that mastering JavaScript fundamentals is still one of the best investments you can make as a developer.
let instead of var for quite a while but I didn’t really know whyvar because I constantly saw code examples and AI code using let and constlet because I saw it as the modern equivalent to var)var is function scopedlet and const are block scopedconst is for variables whose value needs to remain constant, but they are still mutable.function keyword methodfunction keyword as I find the syntax more readable// Function Keyword
function add(num1, num2) {
return num1 + num2;
}
// Arrow Function - same as above, less lines
const add = (num1, num2) => num1 + num2;
Concise Body (no curly braces, implicit return)
// Concise body
const add = (num1, num2) => num1 + num2;
add(2, 3); // 5
Block Body (curly braces, explicit return required)
//Block Body with curly braces, explicit return required
const add = (num1, num2) => {
return num1 + num2;
};
add(2, 3); // 5
Returning an object literal
//Returning an object literal
const getUser = () => ({ name: "Matt", role: "Creator" });
getUser();
// { name: "Matt", role: "Creator" }
This vs This
In JavaScript, regular functions and arrow functions treat the word this very differently. A regular function decides what this means at the moment you call it. An arrow function doesn’t do that at all - instead, it permanently borrows this from wherever it was originally created.
Imagine I have a user object with two methods. One is a normal function, and one is an arrow function. When I call the normal method — the regular function — it looks at the object it’s sitting inside and says: ‘Great, that’s my this.’ So it prints the user’s name just fine.
But the arrow function doesn’t do that. Arrow functions don’t bind their own this at all. Instead, they reach outward and grab whatever this meant in the surrounding scope — which, in this case, is not the user object. So when I call the arrow method, it tries to read this.name, but this isn’t the user anymore. That’s why it prints undefined.
“So the rule of thumb is: if you need a method on an object to use this, don’t use an arrow function. Arrow functions are great for callbacks and utilities, but not for object methods that rely on this.”
const user = {
name: "Matt",
regularMethod: function () {
console.log("regularMethod says:", this.name);
},
arrowMethod: () => {
console.log("arrowMethod says:", this.name);
}
};
user.regularMethod(); // Console: Matt
user.arrowMethod(); // Console: Undefined // Array Destructuring
const bethesdaGames = ["Fallout 3", "Oblivion", "Doom 3"];
const [fallout, tes, doom] = bethesdaGames;
/*
fallout = Fallout 3
tes = Oblivion
doom = Doom 3
*/ bethesdaGames with three values in it (fallout 3, oblivion, and doom 3Fallout 3, and put it inside the fallout variableOblivion, goes into the variable tesDoom 3, goes inside the variable doomconst fallout = {
type: "TV Show",
seasons: 2,
distribution: "Prime Video"
}
const { type, seasons, distribution } = fallout;
/*
type = TV show
seasons = 2
distribution = Prime Video
*/Let’s say I have an object that describes the Fallout TV show. It has three properties: the type of show, how many seasons it has, and where it’s distributed.
“Now, normally, if I wanted to use those values, I’d have to write things like fallout.type or fallout.seasons. But JavaScript gives us a shortcut called destructuring. It lets us pull those values out into their own variables in one clean move.”
“So I write: const { type, seasons, distribution } = fallout;And just like that, I now have three standalone variables — type, seasons, and distribution — each holding the matching value from the object.”
“After destructuring, type is literally the string ‘TV Show,’ seasons is the number 2, and distribution is ‘Prime Video.’ It’s like unpacking a suitcase: the object stays intact, but now you’ve laid out the items you need right on the table.
Is there any other fundamental or “meta” concept(s) that I should explore because they’re used constantly in modern web dev tooling (ie Svelte, React)?
Prices subject to change and are listed in USD
Learn to code using Scrimba with their interactive follow-along code editor.
Join their exclusive discord communities and network to find your first job!
Use our affiliate link for a 20% discount!!
We receive a monetary kickback if you use our affiliate link and make a purchase.