You need to change 3 things in your code:
var privateField = "hello"
with this.privateField = "hello"
.privateField
with this.privateField
.privateField
with this.privateField
.The final code would be the following:
TestClass = function(){
this.privateField = "hello";
this.nonProtoHello = function(){alert(this.privateField)};
}
TestClass.prototype.prototypeHello = function(){alert(this.privateField)};
var t = new TestClass();
t.prototypeHello()