I am trying to program a simple facebook app. In the code I need, I discovered this:
// Load the SDK asynchronously
(function(d){
var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
ref.parentNode.insertBefore(js, ref);
}(document));
How come this function is wrapped up in () and (document) is slapped on at the end? I haven't seen this JavaScript sorcery before.
Thanks for any input.