It's a self-executing anonymous function - with a return value.
I know there is a Javascript variable saveFile being used as a function, passing the parameter "file", but I've never seen the last line of code used before.
This is not what is happening. saveFile is not the function - it's a variable that's assigned a value that is returned from that function.
Here's what the engine does when it runs that code:
- Define the anonymous function.
- The anonymous function is immediately followed by parenthesis which means the anonymous function should be invoked immediately.
- The expression
typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content is evaluated and the resulting value is used as the argument for the file parameter for the anonymous function.
- The anonymous function runs its code and returns a value.
- That return value is then stored in
saveFile.
It's equivalent to doing this:
function anonymous_function( file ) {
// do the stuff
}
var fileArg = typeof self !== "undefined" && self || typeof window !== "undefined" && window || this.content;
var saveFile = anonymous_function( fileArg );
typeofor the use of the logical operators.} ( stuff );syntax which is a hallmark of a SEAF.