Languages
[Edit]
EN

JavaScript - detect Apple device

9 points
Created by:
Niac
508

In this short article, we would like to show how detect Apple device using JavaScript.

Quick solution:

// ONLINE-RUNNER:browser;

var expression = /(Mac|iPhone|iPod|iPad)/i;

function isApple() {
    return expression.test(navigator.platform);
}


// Usage example:

if (isApple()) {
    console.log('You are on Apple device.');
} else {
    console.log('You are not on Apple device.');
}

 

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join