🧾 Basic Syntax
- Use
console.log()
for output - Comments:
// single line
or/* multi-line */
- Indent with 2 spaces or tabs
🧪 Data Types
- Primitive types:
string
,number
,boolean
,null
,undefined
,symbol
- Arrays:
const arr = [1, 2, 3]
- Objects:
const obj = { key: 'value' }
🔄 Control Structures
- Conditional:
if (condition) { ... } else if (...) { ... } else { ... }
- Loops:
for (let i = 0; i < 5; i++) { ... } while (condition) { ... } do { ... } while (condition)
🧠 Functions
- Function declaration:
function myFunction() { ... }
- Arrow functions:
const sum = (a, b) => a + b
- Parameters:
function greet(name = 'Guest') { ... }
🧱 Objects & Arrays
- Object methods:
const person = { name: 'Alice', greet: function() { ... } };
- Array methods:
.map()
,.filter()
,.reduce()
🚀 ES6+ Features
- Template literals: ``
Hello ${name}
` - Destructuring:
const { name, age } = person;
- Spread operator:
const newArr = [...arr, 4, 5]
⚠️ Common Errors
- Forgetting semicolons
- Using
==
instead of===
- Scope issues with
var
vslet
For deeper understanding, check our JavaScript Fundamentals tutorial.