Last active
December 19, 2015 21:39
-
-
Save i-Hun/6022017 to your computer and use it in GitHub Desktop.
Revisions
-
i-Hun revised this gist
Jul 17, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,8 @@ arguments -- переменная, доступная внутри функци arguments.pop() // ошибка ! Можно, однако, вызвать методы Array через apply/call: var args = Array.prototype.slice.call(arguments, 0) //Мы вызываем метод slice прототипа Array от лица arguments. .slice - ищет прототип slice в прототипах массива, то-есть глубокий поиск, начиная от экземпляра созданного массива call(...) - вызывает конструктор для наполнения его тем что есть в контексте. , 0 -- после передачи контекста в call можно передавать параметры. Передаём 0, чтобы slice применялся с самого первого элемента. -
i-Hun revised this gist
Jul 17, 2013 . 2 changed files with 13 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ # Prototype http://habrahabr.ru/post/117868/ arguments -- переменная, доступная внутри функции и содержащая аргументы и ссылку на саму функцию. Несмотря на доступ по индексу и наличие свойства length, arguments не является массивом, т.е не принадлежит типу Array. Поэтому для arguments нельзя напрямую вызвать методы этого класса: arguments.pop() // ошибка ! Можно, однако, вызвать методы Array через apply/call: var args = Array.prototype.slice.call(arguments) //Мы вызываем метод slice прототипа Array от лица arguments. .slice - ищет прототип slice в прототипах массива, то-есть глубокий поиск, начиная от экземпляра созданного массива call(...) - вызывает конструктор для наполнения его тем что есть в контексте. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +0,0 @@ -
i-Hun created this gist
Jul 17, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # Prototype http://habrahabr.ru/post/117868/ arguments -- переменная, доступная внутри функции и содержащая аргументы и ссылку на саму функцию.