A foundation for functional programming in JavaScript