what's best practice when it comes to keeping track of an object reference in javascript:
function class1(param) {
this.param = param;
self = this;
}
class1.prototype.method1 = function () {
console.log(self.param);
}
$('document').ready(function () {
object1 = new class1('foo');
object2 = new class1('bar');
object1.method1(); // expected: foo , actual: bar
})
Currently self appears to be global and is overridden in the constructor of object2. I'd be very grateful if someone could offer some advice.