functional programming bits for Javascript