Nodejs Utililty Methods String Sub String from Left

List of utility methods to do String Sub String from Left

Description

The list of methods to do String Sub String from Left are organized into topic(s).

Method

left(cnt)
if(!String.prototype.left){
  String.prototype.left = function(cnt){
    return this.substr(0,cnt);
  };
if(!String.prototype.right){
  String.prototype.right = function(cnt){
    return this.substr(this.length - cnt,this.length);
  };
...
left(count)
String.prototype.left = function(count) {
    if (count >= this.length) {
        return this.toString();
    }else {
        return this.slice(0, count);
};
left(count)
String.prototype.left = function (count) {
    return this.substring(0, count);
left(count)
String.prototype.left = function(count) {
    var result = "";
    var stringLength = this.length;
    if (count > stringLength) {
        count = stringLength;
    var i;
    for (i = 0; i < count; i += 1) {
        result += this[i];
...
left(count)
String.prototype.left = function(count) {
    if (count > this.length) return this.toString();
    return this.substring(0, count);
};
left(i)
String.prototype.left = function(i)
    if (this.length > i) return this.substr(0, i) + "...";
    return this;
};
left(n)
String.prototype.left = function(n) {
  return this.substr(0,n)
left(n)
String.prototype.left = function(n) {
  return this.substr(0,n);
};
left(n)
String.prototype.left = function(n) {
    return this.slice(0, n);
left(num)
String.prototype.left = function(num) {
  var result = '';
  for (var i = 0; i < num; i++) {
    result += this[i];
  };
  return result;