【取整】
①parseint(解析整型,丢弃小数部分,保留整数部分)
语法:var a =parseint(5/2);
console.log(a) 输出2
②math.ceil(向上取整,有小数就整数部分加1)
语法:math.ceil(5/2) 输出3
③math.round(四舍五入)
语法:math.round(5/2) 输出3
④math.floor(向下取整)
math.floor(5/2) 输出2
【字符串分割】
方法一:分割字符串:string.substring(begin,end) 从begin开始到end,不算begin
实例:
substring=item000003-2;
for(var i=0;i
items_1.push(inputs[i]);
}else{
for(var j=0;j
}
}
}
方法二:split() 方法将字符串分割为字符串数组,并返回此数组
stringobject.split(separator,limit)
注意:如果把空字符串 ("") 用作 separator,那么 stringobject 中的每个字符之间都会被分割
实例:var ch ='i,like,eat-chicken' ;
console.log(ch.split(','))
Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号