Dropzone.js: __slice = [] .slice

I am in the middle trying to figure out at least parts of the fantastic dropzone.js. I am pretty green with a JavaScript idea and a prototype paradigm. There is a line of code right on the fourth line, which I wonder what it does, and why use such a line. The line is as follows:

var __slice = [].slice

Did I understand correctly that this takes a slice function from an array prototype object and just gives it a slightly simpler way to refer to it? What is the advantage of this approach? And why double underlining at the beginning? I read somewhere that this will prevent conflicts in the global area, but this can no longer be avoided by wrapping all the code in

(function() { //code here
}).call(this);

to build?

+4
source share
1

, slice ?

.

?

__slice Array.prototype.slice ( ), [].slice . , , , .

? - , , , ...

, , . , , , , / Array.prototype.slice. __ .

+3

Source: https://habr.com/ru/post/1662013/


All Articles