(function() {
just runs //some code , but the variables will not remain in it, since the function() { } block introduces a new inner scope.
Designation
function() { } is called closure, it allows variables to be functions. For instance,
(function() { })() is a common JavaScript idiom. After ) exists () , which causes the before as function expression, so (callback || function(x) { return x; })(x) is permitted.
var a = function a() { return 1; }
var VARIABLE = VARIABLE || {}; uses a short circuit OR If VARIABLE not defined, VARIABLE will be set to {} , an empty object. (otherwise, if VARIABLE exists, it will not change)
x = A || B x = A || B means "If A evaluates to TRUE, x equals A, otherwise x equals B.".
VARIABLE.methodCall , as you said, adds methodCall to VARIABLE without deleting other values ββin VARIABLE
source share