| name | javascript-mastery |
| description | 33+ essential JavaScript concepts every developer should know, inspired by [33-js-concepts](https://github.com/leonardomso/33-js-concepts). |
| category | Development & Code Tools |
| source | antigravity |
| tags | ["javascript","node","api","ai","cro"] |
| url | https://github.com/sickn33/antigravity-awesome-skills/tree/main/skills/javascript-mastery |
🧠 JavaScript Mastery
33+ essential JavaScript concepts every developer should know, inspired by 33-js-concepts.
When to Use This Skill
Use this skill when:
- Explaining JavaScript concepts
- Debugging tricky JS behavior
- Teaching JavaScript fundamentals
- Reviewing code for JS best practices
- Understanding language quirks
1. Fundamentals
1.1 Primitive Types
JavaScript has 7 primitive types:
const str = "hello";
const num = 42;
const float = 3.14;
const big = 9007199254740991n;
const bool = true;
let undef;
const empty = null;
const sym = Symbol("description");
Key points:
- Primitives are immutable
- Passed by value
typeof null === "object" is a historical bug
1.2 Type Coercion
JavaScript implicitly converts types:
"5" + 3;
"5" - 3;
Boolean("");
Boolean("hello");
Boolean(0);
Boolean([]);
"5" == 5;
"5" === 5;
Falsy values (8 total):
false, 0, -0, 0n, "", null, undefined, NaN
1.3 Equality Operators
null == undefined;
"1" == 1;
null === undefined;
"1" === 1;
Object.is(NaN, NaN);
Object.is(-0, 0);
Rule: Always use === unless you have a specific reason not to.
2. Scope & Closures
2.1 Scope Types
var globalVar = "global";
function outer() {
var functionVar = "function";
if (true) {
let blockVar = "block";
const alsoBlock = "block";
var notBlock = "function";
}
}
2.2 Closures
A closure is a function that remembers its lexical scope:
function createCounter() {
let count = 0;
return {
increment() {
return ++count;
},
decrement() {
return --count;
},
getCount() {
return count;
},
};
}
const counter = createCounter();
counter.increment();
counter.increment();
counter.getCount();
Common use cases:
- Data privacy (module pattern)
- Function factories
- Partial application
- Memoization
2.3 var vs let vs const
var x = 1;
var x = 2;
let y = 1;
const z = 1;
const obj = { a: 1 };
obj.a = 2;
obj.b = 3;
3. Functions & Execution
3.1 Call Stack
function first() {
console.log("first start");
second();
console.log("first end");
}
function second() {
console.log("second");
}
first();
Stack overflow example:
function infinite() {
infinite();
}
infinite();
3.2 Hoisting
console.log(a);
var a = 5;
console.log(b);
let b = 5;
sayHi();
function sayHi() {
console.log("Hi!");
}
sayBye();
var sayBye = function () {
console.log("Bye!");
};
3.3 this Keyword
console.log(this);
const obj = {
name: "Alice",
greet() {
console.log(this.name);
},
};
const obj2 = {
name: "Bob",
greet: () => {
console.log(this.name);
},
};
function greet() {
console.log(this.name);
}
greet.call({ name: "Charlie" });
greet.apply({ name: "Diana" });
const bound = greet.bind({ name: "Eve" });
bound();
4. Event Loop & Async
4.1 Event Loop
console.log("1");
setTimeout(() => console.log("2"), 0);
Promise.resolve().then(() => console.log("3"));
console.log("4");
Execution order:
- Synchronous code (call stack)
- Microtasks (Promise callbacks, queueMicrotask)
- Macrotasks (setTimeout, setInterval, I/O)
4.2 Callbacks
function fetchData