This commit is contained in:
Ilya Kantor 2014-11-16 01:40:20 +03:00
parent 962caebbb7
commit 87bf53d076
1825 changed files with 94929 additions and 0 deletions

View file

@ -0,0 +1,13 @@
Вызов `arr[2]()` -- это обращение к методу объекта `obj[method]()`, в роли `obj` выступает `arr`, а в роли метода: `2`.
Поэтому, как это бывает при вызове функции как метода, функция `arr[2]` получит `this = arr` и выведет массив:
```js
//+ run
var arr = ["a", "b"];
arr.push( function() { alert(this); } )
arr[2](); // "a","b",function
```

View file

@ -0,0 +1,14 @@
# Вызов в контексте массива
[importance 5]
Каким будет результат? Почему?
```js
var arr = ["a", "b"];
arr.push( function() { alert(this); } )
arr[2](); // ?
```