InterviewHubPRO
Section Overview
Q146

Question 146 of 521

Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

28%
JavaScript Internals (521 Qs)•Part 3: DOM, Event Flow, Timers & Browser APIs (104 - 173)

What is the way to find the number of parameters expected by a function

You can use function.length syntax to find the number of parameters expected by a function. Let's take an example of sum function to calculate the sum of numbers,

javascript
  function sum(num1, num2, num3, num4) {
    return num1 + num2 + num3 + num4;
  }
  sum.length; // 4 is the number of parameters expected.