JavaScript Math.max() Function Behavior

🧠 This JavaScript Output Looks Impossible… But It Runs! Read carefully 👇 Don’t rush. console.log(Math.max()); console.log(Math.min()); console.log(Math.max(1, 2, 3)); console.log(Math.max([1, 2, 3])); No loops. No async. No tricky operators. Just Math. Still… the output surprises almost everyone 😄 🤔 Why this question feels different Hardly anyone practices empty arguments Shows how JS handles missing values Mixes numbers vs arrays in a subtle way Looks very beginner-friendly, but seniors pause 💬 Your Turn Comment your answers like this 👇 Line 1 → Line 2 → Line 3 → Line 4 → Try answering without running the code 🤓 I will post the correct output + simple explanation in the evening. 📌 Note: This is to understand JavaScript behavior, not to encourage confusing code. #JavaScript #FrontendDevelopment #LearnJS #CodingInterview #TechWithVeera #WebDevelopment #100DaysOfCode

  • text

Line 1 → -Infinity Line 2 → Infinity Line 3 → 3 Line 4 → NaN Correct way to use array with Math.max console.log(Math.max(...[1, 2, 3])); output: 3

To view or add a comment, sign in

Explore content categories