Hello,
I’m trying to get a better handle on the distinctions between various JavaScript definitions/terms. I’m finding that these distinctions can often be quite subtle or just completely confusing. I’m using this Basic JavaScript challenge as an example:
Manipulate Arrays With push Method
An easy way to append data to the end of an array is via the push()
function.
.push()
takes one or more parameters and “pushes” them onto the end of the array.
Examples:
// Setup
const myArray = [["John", 23], ["cat", 2]];
// Only change code below this line
myArray.push(["dog", 3])
arr1
now has the value [1, 2, 3, 4]
and arr2
has the value ["Stimpson", "J", "cat", ["happy", "joy"]]
.
So starting with the title the word method is used, but then in the next line the word function is used. I’ve gone to other sites and it seems that the terms function and method are distinct from each other. So why the seeming interchangeability here?
Continuing on, the word parameter is used to describe what seems to me are values :
arr1.push(4);
Is the number 4 not a value instead of a parameter? From what I’ve been able to learn a parameter is defined as a variable that acts like a placeholder for values. But then the last sentence uses the word values to describe what was previously referred to as parameters.
I’ve been really struggling to nail down some of these definitions. It seems like a lot of terms are used interchangeably when maybe they shouldn’t be??
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36
Challenge: Basic JavaScript - Manipulate Arrays With push Method
Link to the challenge: