Python Nested Function Variable Javascript Array Filter Unique