On the Internet I found 2 approaches in programming, help me figure out how they are properly named, and in what case which one is better to use.
Links to literate manuals are welcome :)
Approach # 1:
var myVar = function() { return { myFunc: function() { ... } }; }(); myVar.myFunc()
Approach # 2:
function myClass(){ this.myProperty = 1; this.myFunction = function(){ ... } }; myVar = new myClass(); myVar.myProperty = 1; myVar.myFunction();