I'm a java programmer and I'm trying to create something as close to a public static class in JS.
This is how I would code it in java:
class Static{
private static final int privInt;
public static int pubInt;
static{
privInt = 5;
}
public int pubMeth(){
return privMeth();
}
private static int privMeth(){
return false;
}
}
I'm struggling to choose from two alternatives:
var Static1 = new function(){
var privInt;
this.pupInt = 5;
privInt = 5;
this.pupMeth = function(){
return privMeth();
};
function privMeth(){
return false;
};
};
var Static2 =(function(){
var privInt;
privInt = 5;
function privMeth(){
return false;
}
return{
pubInt: 5,
pubMeth: privMeth
};
})();
Maybe they're just syntactical flavours of the same thing, however netbeans are treating them differently? Which one should I go with, or is there yet another, better way?