Awkward way of executing JavaScript code [duplicate]

This is a poor example. Consider the following:

var a = (function() {
  var ret = {};
  ret.test = "123";

  function imPrivate() { /* ... */ }
  ret.public = function() {
    imPrivate();
  }
  return ret;
})();

console.log(a)

a will contain the varible test and the function public, however you can not access imPrivate. This is the common way to handle public vs private variables;

See Why is this function wrapped in parentheses, followed by parentheses? for more info.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)