EN
JavaScript - detect Apple device
9
points
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.');
}