Javascript Array Methods Foreach Python