๐๐š๐ซ๐š๐ฆ๐ž๐ญ๐ž๐ซ๐ฌ ๐ฏ๐ฌ. ๐€๐ซ๐ ๐ฎ๐ฆ๐ž๐ง๐ญ๐ฌ?

idrisso

Mohamed Idris

Posted on July 28, 2022

๐๐š๐ซ๐š๐ฆ๐ž๐ญ๐ž๐ซ๐ฌ ๐ฏ๐ฌ. ๐€๐ซ๐ ๐ฎ๐ฆ๐ž๐ง๐ญ๐ฌ?

Parameters are variables that are used to store the data that's passed into a function for the function to use.

On the other hand, Arguments are the actual data (values) that's passed into a function when it is invoked.

example: Are x and y "parameters" or "arguments" in the below function?

function findAverage(x,y) {
  let avg = (x + y) / 2;
  return avg;
}

console.log(findAverage(11, 7));
Enter fullscreen mode Exit fullscreen mode

Answer:

x and y are parameters! They are defined in the function declaration. The values 11, and 7 are passed in as function arguments.

Credits: Udacity

๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
idrisso
Mohamed Idris

Posted on July 28, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About