Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What difference does the _(underscore) before the function call add() make?

$.each(data, function(i){
        _(catalog.add(this));//iterating through each object in objectStore
});

I was wondering what difference does it make if i exclude the underscore before the function call.

Update

The OP is referring to the jquery indexeddb plugin.

like image 439
Spinbad Avatar asked Nov 17 '12 09:11

Spinbad


People also ask

What is difference between _ and __ in Python?

Enforced by the Python interpreter. Double Leading and Trailing Underscore( __var__ ): Indicates special methods defined by the Python language. Avoid this naming scheme for your own attributes. Single Underscore( _ ): Sometimes used as a name for temporary or insignificant variables (“don't care”).

What does _ before a function mean?

Leading Underscore before variable/function /method name indicates to the programmer that It is for internal use only, that can be modified whenever the class wants.

What does _ in front of function mean in Python?

Python automatically stores the value of the last expression in the interpreter to a particular variable called "_." You can also assign these value to another variable if you want.

What does an underscore before a variable mean?

An underscore in front usually indicates an instance variable as opposed to a local variable. It's merely a coding style that can be omitted in favor of "speaking" variable names and small classes that don't do too many things. Follow this answer to receive notifications.


1 Answers

It calls a function called _ and passes the result of the expression catalog.add(this) as the first and only argument.

That function is quite likely the one defined by the library you can download from underscorejs.org, which is another in a series of libraries that lack intention revealing variable names.

like image 61
Quentin Avatar answered Oct 18 '22 10:10

Quentin