No, when constructing a function you could pass parameters - this case, two is required- which would serve as placeholders when the function is now being called with real values.
The words parameter and argument are often used
interchangeably, but they are distinctively different.
When passing values to a classic JavaScript function
parameters are a convenience but not a necessity.
A classic JavaScript function,function(){return “I am Function”},
has an automatically created arguments object.
Values can be passed to a function with out any parameters.
function noParams(){return arguments[0]+arguments[1]}
alert(noParams(1,2))// alerts 3
In conclusion, parameters are Not passed to
JavaScript functions, values and references
are passed and received by the arguments
object and by parameters if they are included.
Ok, we’re entering confusing waters here! If I ask you “A equals 1. What’s A and what’s 1?” The correct answer would be “Depends”:
/**
* From variable’s point of view
* A - variable name
* 1 - it’s value
*/
const a = 1;
/**
* From objects’s point of view
* A - key or property
* 1 - value
*/
const obj = { a: 1 };
/**
* From functions’s point of view
* A - parameter
* 1 - argument
*/
const fn = (a) => a + 1;
fn(1);
@divya_saini, I hope this will also answer your question.