Introduction to JavaScript
Introduction to JavaScript
🎯 After reading this lesson
After finishing this lesson, you will be able to confidently do the following 3 things.
- ▸✅ var · let · const differences + hoisting behavior
- ▸✅ 7 types + the typeof trap (typeof null === 'object')
- ▸✅ Script loading differences (defer · async · module)
Keep the learning objectives as a checklist and close the lesson once you can answer all of them.
What is JavaScript — *the brain of the web*
Core in one line
JavaScript = a programming language that makes web pages dynamic. Created by Brendan Eich in just 10 days in 1995. Now one of the most widely used languages in the world.
Why is it called JavaScript
Despite the name, it has almost nothing to do with Java. When Java was hot in 1995, a similar name was attached for marketing reasons. In reality it is a functional language closer to Lisp and Scheme than to Java.
> 💡 Java and JavaScript = as unrelated as "ham and hamster".
The 3 faces of JavaScript
It originally ran only inside the browser. Now:
1. Browser — dynamic behavior: clicks, input, animations, etc.
2. Server (Node.js, 2009~) — back-end development, just like Java or Python
3. Mobile & Desktop — app development with React Native and Electron
Front-end, back-end, and mobile, all with the same language. That is JavaScript's overwhelming strength.
Variables — let · const · var
Rule: Always reach for const first. Use let when reassignment is needed. var is only for pre-2015 code.
Primitive types
Functions are values too — store them in variables and pass them as arguments:
The most confusing part — == vs ===
console.log(0 === false); // false ← types are different (number vs boolean)
javascriptconsole.log("1"); // ① Execute immediately
setTimeout(() => console.log("2"), 0); // ⏳ To the queue — even 0 seconds means "later"
console.log("3"); // ② Execute immediately
// 📤 Output order: 1, 3, 2
// → Synchronous code (1, 3) finishes first, then the setTimeout callback (2) executes
javascriptasync function fetchUser(id) {
const res = await fetch(/api/users/${id});
const data = await res.json();
return data;
}
``
While await` is waiting, JS does other work. Even 10,000 concurrent requests are no problem.
Summary
- ▸Dynamic typing: any value in any variable
- ▸Async-first: async/await is the standard
- ▸Functions as first-class citizens: treated like values
- ▸=== instead of == — always
JS evolved from a ridiculed language into one that rules the world. You simply cannot do modern web development without it.
⚡ Try it yourself — JS variables and functions
🤖 Try prompting AI like this
Knowing the concepts from this lesson lets you give AI specific, precise instructions. Instead of a vague 'fix this,' you make vocabulary-backed requests — and that is the starting point for saving tokens.
- ▸'Refactor this JavaScript code by applying Introduction to JavaScript concepts'
- ▸'Give me 3 points about Introduction to JavaScript that come up frequently in interviews'
- ▸'Check this code for anti-patterns related to Introduction to JavaScript'
Why does this save tokens
When you don't know the concepts, you have to ask 'What does that mean?' again after receiving an AI answer. That follow-up question is what eats up tokens. Learn the concepts once and the conversation ends in a single exchange.