Home > Web Front-end > JS Tutorial > js substring gets the specified length string from the right (sample code)_javascript skills

js substring gets the specified length string from the right (sample code)_javascript skills

WBOY
Release: 2016-05-16 17:07:35
Original
1172 people have browsed it

如下所示:

复制代码 代码如下:

 /*

   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); 

}; 
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template