Functional javascript programming