Which is the best way to reference a private method from returned object in javascript? I leave you some sample code:
var HelloWorld = (function(){
var hello = function(){
console.log("hello")
},
return{
addToList: function(){
//how can i reference hello from here dynamically like:
//this["hello"] or this["hell" + "o"]
}
}
})()
this['hello']();seems fine to me...hellofunction declaration, not a comma.,before the return/after the hello function should be a;.