Quantcast
Viewing latest article 11
Browse Latest Browse All 38

Comment from Jack Turner

Your code example can be made even clearer by returning the object containing the public properties and functions rather than storing it in the "obj" variable:
MyObject = function(){

  var privateMethod = function(){ /* do stuff */ };
  
  return {
    publicProperty:5,
    publicMethod:function(){ /* do stuff */ };
  };
}(); // run it right away
Any downsides to this?

Viewing latest article 11
Browse Latest Browse All 38

Trending Articles