JavaScript Notes
JavaScript (JS):
----------------
- High-level, dynamic programming language used to create interactive effects on web pages.
Key Concepts:
1. Variables:
- var, let, const: var is function-scoped, let and const are block-scoped.
- const for constants, let for variables that may change.
2. Data Types:
- Primitive: String, Number, Boolean, null, undefined, Symbol.
- Non-Primitive: Objects (Array, Functions, etc.).
3. Functions:
- Declaration: function name() { ... }
- Arrow function: const func = () => { ... }
- Higher-order functions: Functions that take or return other functions (e.g., map, filter).
4. Control Structures:
- if-else, switch, for loop, while loop, do-while.
5. Objects:
- Key-value pairs: const obj = { key: 'value' }.
- Accessing properties: obj.key or obj['key'].
- Methods: Functions associated with objects.
6. DOM Manipulation:
- Accessing elements: document.getElementById(), document.querySelector().
- Modifying content: element.innerHTML, element.textContent, element.style.
- Event handling: element.addEventListener('click', function).
7. Asynchronous Programming:
- Callbacks, Promises, and async/await for handling asynchronous code.
- fetch API for making HTTP requests.
8. Error Handling:
- try...catch for managing runtime errors.
9. ES6+ Features:
- Template literals, Destructuring, Spread/Rest operators, Classes, Modules (import/export).
JavaScript Libraries & Frameworks:
- jQuery, React.js, Vue.js, Angular.js (for UI development and efficient DOM manipulation).