Functional Javascript skeleton