Created
October 12, 2022 07:04
-
-
Save kurt-liao/4eb87ee5b1b1a01b4cfc3d25a8493c65 to your computer and use it in GitHub Desktop.
常用的 helper methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 判斷變數值是否是 Primitive | |
*/ | |
const isPrimitive = (val: any) => { | |
if (val == null) return true | |
if (typeof val === 'object' || typeof val === 'function') return false | |
return true | |
} | |
/** | |
* 判斷網頁是否是用 webview 開啟的 | |
*/ | |
const isWebView = () => { | |
const userAgent = window.navigator.userAgent.toLowerCase() | |
const safari = /safari/.test(userAgent) | |
const ios = /iphone|ipod|ipad/.test(userAgent) | |
return typeof window.Android !== 'undefined' || (ios && !safari) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment