Is it possible in JavaScript to create a private variable which can be accessed in prototype? I tried the following which obviously doesn't work, because bar is only accessible from within Foo and not from within prototype.
function Foo() {
var bar = 'test';
}
Foo.prototype.baz = function() {
console.log(bar);
};
I know I also cannot use this.bar = 'test', because that would make the property public AFAIK. How to make the bar variable private, but accessible by prototype?