Detects whether the page is being viewed on a mobile device or a desktop.
Navigator.userAgent
property to figure out if the device is a mobile device or a desktop.const detectDeviceType = () =>
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
navigator.userAgent
)
? 'Mobile'
: 'Desktop';
detectDeviceType(); // 'Mobile' or 'Desktop'
JavaScript, Browser
Creates an object containing the parameters of the current URL.
JavaScript, Browser
Returns an array of HTML elements whose width is larger than that of the viewport's.
JavaScript, Browser
Runs the callback whenever the user input type changes (mouse
or touch
).