Use length property from function in JavaScript

Description

The following code shows how to use length property from function.

Example


<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function sayName(name){<!--from   w  w  w .  j a v  a 2s.com-->
document.writeln(name);
}

function sum(num1, num2){
return num1 + num2;
}

function sayHi(){
}
document.writeln("hi");
document.writeln(sayName.length); //1
document.writeln(sum.length); //2
document.writeln(sayHi.length); //0


</script>
</head>
<body>
</body>
</html>

Click to view the demo

The code above generates the following result.

Use length property from function in JavaScript