Js substring gets the specified length string of sample code from the right

  • 2020-03-30 01:02:55
  • OfStack

As follows:

   

String.prototype.right = function (length_)  

{  

        var _from = this.length - length_;  

        if (_from < 0) _from = 0;  

        return this.substring(this.length - length_, this.length);  

};  

Related articles: