1. Emailexport const isEmail = (e) => { return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(e) } 2. Mobile phone numberexport const isMobile = (e) => { return /^1[0-9]{10}$/.test(e) } 3. Phone numberexport const isPhone = (e) => { return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(e) } 4. Is it a URL address?export const isURL = (e) => { return /^http[s]?:\/\/.*/.test(e) } 5. Is it a string?export const isNumber = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'String' } 6. Is it digital?export const isNumber = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Number' } 7. Is it boolean?export const isBoolean = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Boolean' } 8. Is it a function?export const isFunction = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Function' } 9. Is it null?export const isNull = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Null' } 10. Is it undefined?export const isUndefined = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Undefined' } 11. Is it a target?export const isObject = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Object' } 12. Is it an array?export const isArray = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Array' } 13. Is it time?export const isDate = (e) => { return Object.prototype.toString.call(e).slice(8,-1)==='Date' } 14. Is it regular?export const isRegExp = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'RegExp' } 15. Is it the wrong object?export const isError = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Error' } 16. Is it a Symbol function?export const isSymbol = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Symbol' } 17. Is it a Promise object?export const isPromise = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Promise' } 18. Is it a Set object?export const isSet = (e) => { return Object.prototype.toString.call(e).slice(8,-1) === 'Set' } export const us = navigator.userAgent.toLowerCase(); 19. Is it a WeChat browser?export const isWeiXin = () => { return ua.match(/microMessenger/i) == 'micromessenger' } 20. Is it a mobile terminal?export const isDeviceMobile =()=>{ return /android|webos|iphone|ipod|balckberry/i.test(ua) } This is the end of this article about commonly used js function methods. For more related commonly used js function content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: MYSQL Left Join optimization (10 seconds to 20 milliseconds)
>>: Html sample code for reading and displaying pictures in a local folder
Table of contents Preliminary preparation Impleme...
The first time I used the essay, I felt quite awkw...
How to define complex components (class component...
This article example shares the specific code for...
Table of contents 1. Install the required environ...
This article example shares the specific code of ...
Table of contents 1. Download the installation pa...
This article example shares the specific code of ...
getElementById cannot get the object There is a s...
The META tag is an auxiliary tag in the head area...
The backend uses the thinkphp3.2.3 framework. If ...
Preface About the performance comparison between ...
Table of contents 1. Solution 2. MySQL character ...
1. Create and run a container docker run -it --rm...
Goal: Create a square whose side length is equal ...