I'm a totally newbie in JavaScript, which i need for a new project. And now I have a problem:
var main = new function() {
this.init = new function() {
//access something.init();
};
this.something = new function () {
this.init = function(){
//do something
//execute somethingother()
};
this.somethingother = function(){
//do something
};
};
};
main.init();
Can you please help me?
If you want to nest functions inside function - you CAN, but you should learn javascript syntax, how lexical scope and variable hoisting works, and overall - read Douglas Crockford's articles (or watch his videos).
The code you have shown will not work, try to look at my modification of it, and understand the difference.
JavaScript doesn't have classes out of the box. You need to implement classes yourself.
One popular implementation is JS.Class, if you don't want to write your own implementation.