Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   
   HTML   
   CSS   
   JAVA SCRIPT   
   JQUERY   




JAVASCRIPT - FUNCTION ARGUMENTS


Say, you want to pass some information to a Function.


For example, if you want a Function to add two numbers. You need to pass those two numbers to the Function.


Say, in the below example, you want the add Function to add two numbers for you. And you have passed those numbers in between the brackets () of the add Function(i.e. firstNumber and secondNumber).


And those elements inside the brackets () of the add Function is called as Parameters and the actual value passed to them is called as Argument.


Example :



<html>
<body>  
<script>

	function add(firstNumber, secondNumber) {
   		let result = firstNumber + secondNumber
   		return result
	}   	

	var firstNum = 5
	var secondNum = 4   	
	var value = add(firstNum, secondNum)
	document.write("The added result is ",value)
	    
</script>      
</body>
</html>


Output :



  The added result is 9

So, the variables inside the add Function is called as Parameter.

java_Collections

And the actual values (i.e. 5 and 4) to be sent to the Function are the Arguments.


Throughout the tutorial we will be calling the Parameters as Arguments to avoid unnecessary confusion.


Now, what if, you have defined a Function with two Argument but made the Function call with one argument.