Nodejs String Capitalize firstToUpper()

Here you can find the source of firstToUpper()

Method Source Code

// ----------------------------------------------------------------------------
// USEFUL STUFF//from   w ww.  j a v a 2  s. c  o  m
// ----------------------------------------------------------------------------

var useful = {}

String.prototype.firstToUpper = function() {
  return this.charAt(0).toUpperCase() + this.slice(1);
}

Array.prototype.shuffle = function() {
  var currentIndex = this.length, temporaryValue, randomIndex ;

  // While there remain elements to shuffle...
  while (0 !== currentIndex) {

    // Pick a remaining element...
    randomIndex = Math.floor(Math.random() * currentIndex);
    currentIndex -= 1;

    // And swap it with the current element.
    temporaryValue = this[currentIndex];
    this[currentIndex] = this[randomIndex];
    this[randomIndex] = temporaryValue;
  }
  return this;
}

useful.clamp = function(value, min, max)
{
  return Math.max(min, Math.min(value, max));
}

useful.lerp = function(a, b, amount)
{
  useful.clamp(amount, 0, 1)
  return ((1-amount)*a + amount*b);
}

Related

  1. ucfirst()
    String.prototype.ucfirst = function(){
      return this.replace(/(^[a-z])/,function(v){return v.toUpperCase();});
    };
    
  2. ucfirst()
    String.prototype.ucfirst = function() {
        return this.substr(0, 1).toUpperCase() + this.substr(1);
    
  3. ucfirst()
    String.prototype.ucfirst = function(){
      var str = this + '';
        return str.charAt(0).toUpperCase() + str.substr(1);
    
  4. ucfirst(str)
    String.prototype.ucfirst = function(str) {
        str += '';
        var f = str.charAt(0).toUpperCase();
        return f + str.substr(1);
    };
    
  5. firstToUpper()
    String.prototype.firstToUpper = function() {
      return this.charAt(0).toUpperCase() + this.slice(1);
    
  6. firstUpper()
    String.prototype.firstUpper = function() {
        return this.charAt(0).toUpperCase() + this.slice(1);
    };