The Date object in JavaScript is used to work with **dates and times**. It can be used to get the current date, time, calculate differences, format time, etc.
const now = new Date();
const specific = new Date('2025-08-05T10:30:00');
getFullYear() → Returns the 4-digit yeargetMonth() → Month (0-11)getDate() → Day of the monthgetHours(), getMinutes(), getSeconds()getTime() → Timestamp (ms since Jan 1, 1970)toLocaleDateString() → Format date nicelyconst now = new Date();
console.log(now.toLocaleDateString()); // 8/5/2025
console.log(now.getFullYear()); // 2025
📚 Reference: MDN Web Docs - Date
The Math object provides basic mathematics functions and constants. It's used for rounding, generating random numbers, getting min/max, etc.
Math.random() → Returns a random number between 0 and 1Math.floor() → Rounds downMath.ceil() → Rounds upMath.round() → Rounds to nearestMath.max(), Math.min() → Highest/Lowest number in a listMath.abs() → Absolute valueMath.pow(x, y) → x to the power of yMath.sqrt(x) → Square rootconst otp = Math.floor(Math.random() * 9000 + 1000); // 4-digit OTP
console.log(otp); // e.g., 4821
console.log(Math.max(10, 2, 99)); // 99
📚 Reference: MDN Web Docs - Math