SoFunction
Updated on 2025-04-03

A brief discussion on js statements similar to (function{}).call

Research the automatic login process of Sina Weibo, which involves its encryption algorithm script, and there is a code in the following form:

(function(){...}).call(name)

The red... is the various internal implementations of the function, and the name is the name of an object. I have never seen this form of js (I am sorry that I have little knowledge of js). Then I asked Baidu about the general meaning as follows:

The function of .call(name) is actually to use name as this in the domain where the previous function is located, that is to say, this in the function is equivalent to referring to name.

The practical significance of this code can be considered as: the specific implementation of the function to transform the variable name, or to put it simply, the implementation of the function is the specific implementation of the variable name, which in a sense is equivalent to:

var name = function(){...}

The above is the entire content of this article, I hope you like it.