JavaScript Fundamentals That Actually Matter in Daily Coding

The Foundation Matters More Than the Framework
Every few months a new JavaScript framework appears, but the language itself stays the same at its core. If you understand the fundamentals, learning React, Vue, or Svelte becomes a matter of learning syntax, not re-learning programming. Here are the JavaScript concepts that matter most in real projects.
Variables: Let vs Const vs Var
Modern JavaScript gives you three ways to declare a variable. In practice, you should use const by default and let when you need to reassign a value.
const apiUrl = "https://api.example.com";
let count = 0;
count = count + 1; // fine
apiUrl = "https://other.com"; // throws TypeError
var is function-scoped, which can lead to subtle bugs. let and const are block-scoped, meaning they only exist inside the {} block where you declared them. This is safer and easier to reason about.
Type Coercion and Truthiness
JavaScript is loosely typed, which means it tries to convert values automatically. This is both a convenience and a trap.
console.log("5" + 3); // "53" - string concatenation wins
console.log("5" - 3); // 2 - the minus operator forces numbers
console.log(0 == false); // true (loose equality)
console.log(0 === false); // false (strict equality)
Always use === (strict equality) unless you have a specific reason not to. Also, remember the falsy values: false, 0, "", null, undefined, and NaN. Everything else is truthy. This matters when you write if (value) checks — an empty string or 0 will not enter the block.
Functions Are First-Class Citizens
In JavaScript, functions are values. You can assign them to variables, pass them as arguments, and return them from other functions.
const greet = (name) => `Hello, ${name}!`;
const shout = (fn, name) => fn(name).toUpperCase();
Arrow functions (=>) are the modern choice for most cases. They're more concise and, importantly, they don't bind their own this. A regular function's this depends on how it's called; an arrow function uses this from the surrounding scope. This behavior is a common source of bugs, especially in event handlers and callbacks.
Closures: The Concept That Unlocks Advanced JavaScript
A closure is a function that remembers the variables from where it was created, even after that scope has finished executing.
function createCounter() {
let count = 0;
return function() {
count++;
return count;
};
}
const counter = createCounter();
console.log(counter()); // 1
console.log(counter()); // 2
Here, the inner function "closes over" the count variable. This is how you create private state, memoization, and many