In JavaScript (and PHP, too), you can save a few lines of code by assigning multiple variables at once. In this example, the function wp.media()
is called and immediately assigned to wp.media.frames.file_frame
. The author wanted to use the same value for mediaUploader
so they added it in the same assignment statement.
Another way to look at it is
// Option 1: single function call, multiple assignments
wp.media.frames.file_frame = wp.media({...});
mediaUploader = wp.media.frames.file_frame;
// Option 2: multiple function calls, multiple assignments
wp.media.frames.file_frame = wp.media({...});
mediaUploader = wp.media({...});
This can be useful if you’re assigning a value to a global object but want to manipulate the value locally without affecting the global. In this case, the author can assign the value to wp.media.frames.file_frame
so it’s available there, and use mediaUploader
locally inside a function without affecting the value of the other scoped variable.