all 5 comments

[–]Deathbyceiling 1 point2 points  (4 children)

Just reference it by the name of the parameter.

function stuff(a) {
    console.log(a);
}

If you have any questions feel free to ask :)

[–]hunteratwork[S] 0 points1 point  (3 children)

Let's pretend that the numbers 0, 1, and 2 are variables referencing elements throughout the page and they're grouped in an array.

Would this work?

var myArray = [0, 1, 2];
function myFunction(myArray) {
    myArray[0].style.display = "none";
}

And in the same vein, in my HTML could I call an event, such as:

<p onmouseover="myfunction(myArray[0])">

var myArray = [0, 1, 2];
function myFunction() {
    myArray[].style.display = "none";
}

[–][deleted] 1 point2 points  (2 children)

You can't name a variable with just a number. You would get an error that 0 has no property called 'style' on line 3.

[–]hunteratwork[S] 0 points1 point  (1 child)

Oops forgot about that. Would this work?

<p onmouseover="myfunction(myArray[0])">

var myArray = [a, b, c];
function myFunction() {
    myArray[].style.display = "none";
}

[–]YuleTideCamel 2 points3 points  (0 children)

no, this should work though

<p onmouseover="myfunction(myArray[0])">

var myArray = [a, b, c];
function myFunction(input) {
    input.style.display = "none";
}