目录1.邮箱2.手机号码3.电话号码4.是否url地址5.是否字符串6.是否数字7.是否boolean8.是否函数9.是否为null10.是否undefined11.是否对象12.是
export const isEmail = (e) => {
return /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/.test(e)
}
export const isMobile = (e) => {
return /^1[0-9]{10}$/.test(e)
}
export const isPhone = (e) =>{
return /^([0-9]{3,4}-)?[0-9]{7,8}$/.test(e)
}
export const isURL = (e) => {
return /^Http[s]?:\/\/.*/.test(e)
}
export const isNumber = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1) === 'String'
}
export const isNumber = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1) ==='Number'
}
export const isBoolean = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1) ==='Boolean'
}
export const isFunction = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1) === 'Function'
}
export const isNull = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1)==='Null'
}
export const isUndefined = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1)==='Undefined'
}
export const isObject = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1) === 'Object'
}
export const isArray = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1)==='Array'
}
export const isDate = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1)==='Date'
}
export const isRegExp = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1)==='RegExp'
}
export const isError = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1)==='Error'
}
export const isSymbol = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1)==='Symbol'
}
export const isPromise = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1)==='Promise'
}
export const isSet = (e) =>{
return Object.prototype.toString.call(e).slice(8,-1) ==='Set'
}
export const us = navigator.userAgent.toLowerCase();
export const isWeiXin = () =>{
return ua.match(/microMessenger/i) == 'micromessenger'
}
到此这篇关于常用的js函数方法的文章就介绍到这了,更多相关常用的js函数内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!
--结束END--
本文标题: 前端常用的js函数方法
本文链接: https://lsjlt.com/news/161215.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-01-12
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
2023-05-20
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0