function isInt(val){
if((typeof(val)=='number')||(val instanceof Number)){
if(/^\d*$/.test(val)){
return true
}else{
return false
}
}else{
return false
}
}
function isFloat(val){
if((typeof(val)=='number')||(val instanceof Number)){
if(/^\d*\.\d*$/.test(val)){
return true
}else{
return false
}
}else{
return false
}
}
function isString(val){
if((typeof(val)=='string')||(val instanceof String)){
return true
}else{
return false
}
}
function isBoolean(val){
if((typeof(val)=='boolean')||(val instanceof Boolean)){
return true
}else{
return false
}
}
function isArray(val){
if(val instanceof Array){
return true
}else{
return false
}
}
function isObject(val){
if(val instanceof Object && typeof val.length == 'undefined'){
return true
}else{
return false
}
}
function isInt(val){
if((typeof(val)=='number')||(val instanceof Number)){
if(/^\d*$/.test(val)){
return true
}else{
return false
}
}else{
return false
}
}
function isFloat(val){
if((typeof(val)=='number')||(val instanceof Number)){
if(/^\d*\.\d*$/.test(val)){
return true
}else{
return false
}
}else{
return false
}
}
function isString(val){
if((typeof(val)=='string')||(val instanceof String)){
return true
}else{
return false
}
}
function isBoolean(val){
if((typeof(val)=='boolean')||(val instanceof Boolean)){
return true
}else{
return false
}
}
function isArray(val){
if(val instanceof Array){
return true
}else{
return false
}
}
function isObject(val){
if(val instanceof Object && typeof val.length == 'undefined'){
return true
}else{
return false
}
}
var a = new Number(1)
var b = new Number(1.1)
var c = new String('a')
var d = new Boolean(true)
var e = new Array(1,2,3)
var f = new Object({name:'lee'})
var aa = 1
var bb = 1.1
var cc = 'f'
var dd = false
var ee = [1,2,3]
var ff = {name:'lee'}
console.log(isInt(a))
console.log(isFloat(b))
console.log(isString(c))
console.log(isBoolean(d))
console.log(isArray(e))
console.log(isObject(f))
console.log(isInt(aa))
console.log(isFloat(bb))
console.log(isString(cc))
console.log(isBoolean(dd))
console.log(isArray(ee))
console.log(isObject(ff))
b. 输出:
true
true
true
true
true
true
true
true
true
true
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。