W dalszej części, drugi i trzeci wyjścia konsoli wydają się sprzeczne:Nieoczekiwane „argumenty” własność na obiekcie
function test() {
console.log(arguments); // -> ["my", "arguments"]
console.dir(this); // -> test function with arguments property set to null
console.log(this.arguments); // -> ["my", "arguments"]
}
test.call(test, 'my', 'arguments');
Jak na moje komentarze, kontroli własnością arguments
na this
pokazuje null
, podczas zalogowaniu this.arguments
wyraźnie pokazuje ["my", "arguments"]
.
Czym dokładnie jest this
, gdy wywołujesz funkcję w taki sposób? Nie oczekiwałem, że this.arguments
będzie zawierać argumenty wywołania!
Pamiętaj, że powielacie to samo, logując się do 'test.arguments'. –