closures and scope in functional JavaScript