Quantcast
Channel: Posts/rss
Viewing all articles
Browse latest Browse all 38

Comment from Jack Turner

$
0
0
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 all articles
Browse latest Browse all 38

Trending Articles