Javascript String trunc(n)
String.prototype.trunc = function(n) { 'use strict';//from w ww . j a v a 2s . c o m 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 = 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; }//w ww . jav a 2 s . com return false; } function clone(obj) { var target = {}; for (var i in obj) { if (obj.hasOwnProperty(i)) target[i] = obj[i]; } return target; }