🛑 This JavaScript Output Looks Boring… But It Isn’t Most developers have never checked this property 👀 Yet it exists in every function. function sum(a, b, c = 10) {} console.log(sum.length); No logic. No return. No execution. Still… answers vary a LOT 😄 🤔 Why this question is interesting Tests function metadata Shows how JS treats default parameters Looks beginner-level Still surprises seniors Very common interview follow-up question 💬 Your Turn Comment your answer 👇 Output → Why? → ⚠️ Please don’t run the code. Think it through. I will post the correct output + simple explanation in the evening. 📌 This post is to understand JavaScript behavior, not production patterns. #JavaScript #LearnJS #FrontendDevelopment #CodingInterview #TechWithVeera #WebDevelopment
Output --> 2 As c =10 is default parameter And . length counts minimum number of arg needed
The 'length' property of a JavaScript function returns the number of required parameters. So answer is 2
2 is correct answer
1
2
2 because default is not counted I mean when js saw the parameter as default it stops counting So suppose the first parameter is the default and the second one is not the default. But length will give 0 because once js sees the default it stops counting.