Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does JavaScript `arguments` contain `this`?

I'm trying to understand JavaScript's arguments implicit variable in functions. Some tutorials delete the 0th element of it and say that it contains this but some other tutorials don't delete the 0th element. I'm very confused.

I wrote this code example and it shows that arguments doesn't contain this:

function aaa () {
    console.log(arguments[0])
}

aaa(1,2,3);

Is it possible that sometimes arguments contains this? I wonder why some tutorials slice away the 0th element before using arguments.

like image 993
bodacydo Avatar asked Oct 26 '25 16:10

bodacydo


1 Answers

most likely you have a function like blah(x) In which case you take off the first argument because it is already captured as the variable x, and you want the rest of the arguments that have been passed in.

The first argument is not this.

like image 179
Keith Nicholas Avatar answered Oct 29 '25 06:10

Keith Nicholas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!