Redefinition of the variable t, in the function ready use t = 2 to invoke the global variable t. With var t = 2 within ready, you are defining another variable only valid within the ready function. Note that the word return leaves the function and will not execute any instructions below. return t is irrelevant here.