Check if user device is iOS or iPadOS in JavaScript

Written by Tom Wells on

Nowadays, retrieving the users' device information is simple. With this code snippet, you'll be able to check if the device is running iOS or iPadOS, which is useful for enabling features specific for Apple users:

const isiOS = () => {
    return navigator.userAgent.match(/ipad|ipod|iphone/i)
}

It really is that simple. For something with a bit more meat to it, learn how to sort dates in an array.