#142💼 Interview💻 Code
What is the way to find the number of parameters expected by a function
Advertisement
728x90
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
1function sum(num1, num2, num3, num4) {
2 return num1 + num2 + num3 + num4;
3 }
4
5sum.length; // 4 is the number of parameters expected.Advertisement
Responsive Ad
🎯 Practice NowRelated Challenge
JavaScript Coding Exercise 57
Test your knowledge with this interactive coding challenge.
Start CodingAdvertisement
728x90
142of476