How to detect macos browser in JavaScript

In this Article we will go through how to detect macos browser only using single line of code in JavaScript.

Let's define this short function:

const isMacBrowser = /Mac|iPod|iPhone|iPad/.test(navigator.platform);