I am having a question about javascript. To get my code organized I have the functions gathered in one variable like this.
var helper = new function(){
this.writeProp = function(){
//write the property
}
this.getProp = function(){
//get property
}
this.updateProp = function(){
//get property
}
}
So far the code is working but and I can call it with helper.getProp()
Now the amount of functions are getting bigger so I want to call the functions like this helper.prop.get()
How can I accomplish this?
My thought was the following but it's not working.
var helper = new function(){
var prop = new function(){
this.write = function(){
//write the property
}
this.getProp = function(){
//get property
}
this.updateProp = function(){
//get property
}
}
}
What would be the right way to do it? Or should I not try to organize my code this way?
propafter all. You'll get every function inprop. Aspropis private variable inside your function and you can not access private variable from your function.new functioninstead of simply{ ... }?new function. See: Joachim Pileborg's answer.