#poll
What do you prefer to read:
A:
function foo() { return 1; }
var foo = foo();
or
B:
var foo = foo();
function foo() { return 1; }
Please comment.
#poll
What do you prefer to read:
A:
function foo() { return 1; }
var foo = foo();
or
B:
var foo = foo();
function foo() { return 1; }
Please comment.
@Qantas94Heavy you are losing scope of the question i'm afraid.
A; the order of declarations let's me know that function foo(){...}
is no longer accessible and var foo
has overwritten it
B, but with a different var name. I agree with Qantas regarding that. I like to see the most summarized code (function call) and then investigate the function elsewhere if I need to. To me, "A" would be like reading through the jQuery library before calling
.hide()
. If I want to know what.hide()
does, I'll look for it and read it. In that light, maybe that function could be in it's own library that is required in and then it doesn't have to be above or below :)