Array functions for AngularJs