JavaScript¶
Master modern JavaScript for interactive web applications.
Quick Start¶
New to JavaScript? Start here:
- Laracasts: JavaScript - The First Steps - Video series
- JavaScript Notes & Reference - Comprehensive guide
Core Learning¶
Fundamentals¶
- ES6 Tutorial - Modern JavaScript features
- ESNext - Latest JavaScript additions
- ECMAScript History - Version evolution
Best Practices¶
- Clean Code JavaScript - Write maintainable code
Required Tools Setup¶
Before coding, install these tools:
- Node.js - JavaScript runtime (Download)
- npm - Package manager (comes with Node.js)
- nvm - Node Version Manager (Install Guide)
Practice Problems¶
Problem 1: Fix the Array Sum Function 🐛¶
Bug: This code has an off-by-one error. Find and fix it!
function sumArray(arr) {
let sum = 0;
for (let i = 0; i <= arr.length; i++) { // ⚠️ Bug here!
sum += arr[i];
}
return sum;
}
console.log(sumArray([1, 2, 3, 4])); // Expected: 10
💡 Hint
Array indices go from 0 to length-1. What happens when i equals arr.length?Problem 2: JavaScript Type Coercion 🔄¶
Predict the output:
let a = 3;
let b = "3";
console.log(a + b); // ?
console.log(b + a); // ?
console.log(b * a); // ?
console.log(a * b); // ?
console.log(a / b); // ?
console.log(b / a); // ?
console.log(a - b); // ?
console.log(b - a); // ?
Question: Why do + and - operators behave differently?
🤔 Deep Dive Topics¶
Master these JavaScript concepts:
- Closures - Functions that remember their scope
- Event Loop - How JavaScript handles async operations
- null vs undefined - Type differences and use cases
- Hoisting - Variable and function declarations
- Promises & Async/Await - Modern asynchronous programming
Test Your Knowledge¶
Goal: Score 70% or higher