JAVASCRIPT BASICS - INTRODUCTION
JavaScript adds interactivity to web pages.
It runs in the browser and on servers (Node.js).
These notes explore syntax, DOM, events, and ES6+ features.
1. SYNTAX & DATA TYPES
- Variables: var, let, const
- Primitives: Number, String, Boolean, null, undefined, Symbol
- Objects & Arrays
2. CONTROL FLOW
- if/else, switch
- Loops: for, while, do...while, for...of, forEach
- Example:
arr.forEach(item => console.log(item));
3. FUNCTIONS & SCOPE
- Function declaration vs arrow functions:
function foo() {} vs const foo = () => {}
- this keyword, closures, block vs function scope
4. DOM MANIPULATION
- Selecting: document.getElementById, querySelector, querySelectorAll
- Changing content: element.textContent, innerHTML
- Creating/removing: createElement, appendChild, removeChild
5. EVENTS & ASYNC
- addEventListener, event object, preventDefault()
- Promises, async/await, fetch API:
fetch('/api/data')
.then(res => res.json())
.then(data => console.log(data));