Looks unnecessarily complicated, what about (similarily below):
```javascript
/(iPad|iPhone|iPod)/g.test(navigator.userAgent)
```