您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。