JavaScript中使用slice()函数可以从右侧取出指定长度的字符串
发布时间:2023-09-02 13:33:06 所属栏目:教程 来源:
导读:如下所示:
代码如下:
/*
Get the rightmost substring, of the specified length,
from a String object.
*/
String.prototype.right = function (length_)
{
var
代码如下:
/*
Get the rightmost substring, of the specified length,
from a String object.
*/
String.prototype.right = function (length_)
{
var
如下所示: 代码如下: /* Get the rightmost substring, of the specified length, from a String object. */ String.prototype.right = function (length_) { var _from = this.length - length_; if (_from < 0) _from = 0; return this.substring(this.length - length_, this.length); }; (编辑:聊城站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
推荐文章
站长推荐