Here you can find the source of trunc(n)
String.prototype.trunc = String.prototype.trunc || function(n){ return this.length>n ? this.substr(0, n-1) + '...' : this; }; function inArray(needle, haystack) { var length = haystack.length; for(var i = 0; i < length; i++) { if(haystack[i] == needle) return true; }/*from w w w .j a va 2 s . c o m*/ return false; } function clone(obj) { var target = {}; for (var i in obj) { if (obj.hasOwnProperty(i)) target[i] = obj[i]; } return target; }
String.prototype.trunc = String.prototype.trunc || function(n){ return (this.length > n) ? this.substr(0,n-1)+'…' : this; };
String.prototype.trunc = function(n) { return this.substr(0,n-1)+(this.length>n?'...':''); };
String.prototype.trunc = function(n){ var isTooLong = this.length > n; var string = isTooLong ? this.substr(0,n) : this; string = isTooLong ? string.substr(0, string.lastIndexOf(' ')) : string; return isTooLong ? string + '...' : string; };
String.prototype.trunc = function(n) { var longStr = this.length > n; var str = longStr ? this.slice(0, n) : this; longStr ? str = str.slice(0, str.lastIndexOf(' ')) : str; return longStr ? str + '...' : str;
String.prototype.trunc = String.prototype.trunc || function(n){ return this.length>n ? this.substr(0, n-1) + '...' : this; }; function inArray(needle, haystack) { var length = haystack.length; for(var i = 0; i < length; i++) { if(haystack[i] == needle) return true; return false; ...
String.prototype.trunc = function(n,useWordBoundary){ var toLong = this.length>n, s_ = toLong ? this.substr(0,n-1) : this; s_ = useWordBoundary && toLong ? s_.substr(0,s_.lastIndexOf(' ')) : s_; return toLong ? s_ : s_; };
String.prototype.trunc = function(n,useWordBoundary) { var toLong = this.length>n , s_ = toLong ? this.substr(0,n-1) : this; s_ = useWordBoundary && toLong ? s_.substr(0,s_.lastIndexOf(' ')) : s_; return toLong ? s_ + '…' : s_; }; String.prototype.startsWith = function (str){ return this.slice(0, str.length) == str; }; ...
String.prototype.trunc = String.prototype.trunc || function(n){ return this.length > n ? this.substr(0,n-1) + "\u2026" : this; };
String.prototype.trunc = String.prototype.trunc || function(n){ return (this.length > n) ? this.substr(0, n-1) + '…' : this; };