Arguments question


#1

We should not define the arguments before we use them in arguments

Means Why we don’t need to define arguments before using inside the function calling ???


#2

Arguments need not be defined (meaning literal) but any object can be an argument. It’s something being passed into a function so why shouldn’t it be defined?

var oranges = 5;

var costOfOranges = function (oranges) {
    return oranges * 5;
}

console.log(costOfOranges(oranges));

// <-  25

There are two oranges variables, not one. They are completely different variables in different scope, just spelled the same.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.