Hey guys I've just started using javascript's prototype and I was wondering if it's possible, and if so, how to call a function inside a method eg:
obj = function(test){
this.test=test;
}
obj.prototype.a = function(){
var x = this.test;
function b(){
alert(x);
}
function c(){
console.log(x);
}
}
var foo = new obj();
foo.a.b();
So, could I access function b inside obj.a without calling function c ie I want to be able to call a and have it call both functions inside it, but also be able to just call b or c if I need to?
I know I could just put these in separate methods outside of a, but I thought I'd ask the question.
Cheers.
amakesbavailable to the outside world. Now, ifahadreturn {b: b}, thenfoo.a().b()would work. Or ifahadreturn b;thenfoo.a()()would work.