返回到:Prototype – 数字处理
此方法将数字转换为用 0 填充的字符串,以便字符串的长度至少等于 length。采用可选的基数参数,该参数指定用于转换的基数。
语法
number.toPaddedString(length[, radix]);
返回值
返回一个字符串。
例子
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
alert("(13).toPaddedString(4) : " + (13).toPaddedString(4) );
alert("(13).toPaddedString(2) : " + (13).toPaddedString(2) );
alert("(13).toPaddedString(1) : " + (13).toPaddedString(1) );
alert("(13).toPaddedString(4, 2): " + (13).toPaddedString(4, 2));
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br />
<br />
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>返回到:Prototype – 数字处理
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8910.html
支付宝
微信