Javascript String substrings(first_argument)

Description

Javascript String substrings(first_argument)

String.prototype.substrings = function (first_argument) {
  var substrings = [];
  for (var i = 0; i < this.length; i++) {
    for (var j = i + 1; j <= this.length; j++) {
      substrings.push(this.substring(i, j));
    }/* ww  w  . j  a v  a  2 s .co m*/
  }
  return substrings;
};

var arr = [1,6,2,4,2,8];
var h = "abc";



PreviousNext

Related