JavaScript Learning Guide
1. Introduction to JavaScript
- JavaScript is the programming language of the web.
- It is used to add interactivity, animations, and dynamic features.
2. Basics
- Variables: let x = 10; const name = 'Harsh'; var age = 20;
- Data Types: Number, String, Boolean, Object, Array, Null, Undefined.
- Output: console.log('Hello World');
3. Operators
- Arithmetic: +, -, *, /, %
- Comparison: ==, ===, !=, >, <
- Logical: &&, ||, !
4. Control Structures
- If-Else: if (x > 0) { console.log('Positive'); } else { console.log('Negative'); }
- Loops: for (let i=0; i<5; i++) { console.log(i); }, while(x < 5) { x++; }
5. Functions
- Functions help reuse code.
- Example: function greet(name) { return 'Hello ' + name; }
- Arrow function: const add = (a,b) => a+b;
6. Arrays & Objects
- Array: let numbers = [1,2,3];
- Object: let person = {name:'Harsh', age:20};
- Access: numbers[0], person.name
7. DOM Manipulation
- document.getElementById('id').innerHTML = 'Hello';
- document.querySelector('.class').style.color = 'red';
8. Events
- onclick, onmouseover, onchange, etc.
- Example: <button onclick="alert('Clicked!')">Click</button>
9. ES6 Features
- let & const, Arrow functions, Template literals, Destructuring.
- Promises and Async/Await for handling asynchronous code.
10. Projects Ideas
- Calculator
- Digital Clock
- To-Do List
- Weather App using API
- Quiz Game
11. Conclusion
- Practice daily with small projects.
- JavaScript is essential for frontend and also works in backend (Node.js).