You're missing a few key things in your examples. I'm only going to focus on the f function, assume the rest of the code is the same:
If you're simply accessing values stored on the object, there's no reason to store a temporary variable, it'll just gunk up the works:
function () {
//use the values as they are
alert( this.a );
alert( this.b );
alert( this.c );
}
However, if you're performing calculations and need to temporarily cache the results for reuse, you should use local variables. Be sure that they don't pollute global scope (the window object); use var to make the variable only persist locally.
function () {
var foo;
foo = this.a / this.b + this.c;
alert( this.a * foo );
alert( this.b / foo );
alert( this.c + foo );
}
Edit to add:
There are two different types of variables being referenced. Variables attached to the object (which are accessed with this.varname or this['varname']) and variables which exist only within local scope (which are declared with var varname and accessed with varname).
Any variable attached to the object is accessible publicly and should be used for revealing data or persistence across function calls. Any variable declared within the function is accessible only within the context of the function, and are therefor private to the function. They do not retain values across calls, however they can be used to retain data across calls to sub-functions.
Between Block A and Block B, Block A is the preferred method for interacting with an object's data, however in most cases a function performs a larger series of operations that often involve more complex behaviors. If the function contained a callback that needed the values of this.a, this.b and this.c, aliases would need to be used to pass the data, as this would change between contexts.
This is not going to alert 1, 2 and 3 as might be expected
f:function ()
{
$(foo).click(function g(){
//`this` does not refer to the object `f` belongs to, but the element being clicked on
//and therefor is not likely to work as expected
alert( this.a );
alert( this.b );
alert( this.c );
});
}
This version will:
f:function()
{
var a,b,c;
a = this.a;
b = this.b;
c = this.c;
$(foo).click(function g(){
alert( a );
alert( b );
alert( c );
});
}
varin that function, so those are global variables you're creating. Anyway, it's not clear what problem it is that you're worried about. There's nothing wrong with copying a value into a local variable, so by that measure it's "correct."