Here you can find the source of trim()
var person = {};//w ww.jav a 2 s. com person.say = function(name){ console.log(name); }; person.say("lilei"); String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); } function trim(str){ return str.replace(/(^\s*)|(\s*$)/g, ""); } console.log(" abc ddd ".trim()); console.log(trim(" zzzzzzzzz ")); function delSpace(str){ return str.replace(/\s*/g,""); } console.log(delSpace(" abc ddd ")); console.log("hello javascript".slice(2,7));
var Firefox = (document.getElementById && !document.all); var MSIE = (-1 != navigator.userAgent.indexOf('MSIE')); String.prototype.trim=function(){ return this.replace(/^\s+|\s+$/g,""); }; function Redirect(url) parent.location=url; var Submitted = 0; function OnSubmit(form) if (Submitted) { return false; Submitted = 1; return true;
String.prototype.trim = function(){ return this.rTrim(this.lTrim());
String.prototype.trim = String.prototype.trim || function () { const str = this.replace(/^\s\s*/, ''); let i = str.length; for (let rgxp = /\s/; rgxp.test(str.charAt(--i));) { return str.substring(0, i + 1); }; ...
'use strict'; Array.isArray = Array.isArray || function (obj) { return {}.call(obj) === '[object Array]'; }; String.prototype.trim = String.prototype.trim || function () { const str = this.replace(/^\s\s*/, ''); let i = str.length; ...
String.prototype.trim=function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); String.prototype.ltrim=function(){ return this.replace(/(^\s*)/g,""); String.prototype.rtrim=function(){ return this.replace(/(\s*$)/g,""); function trim(str){ return str.replace(/(^\s*)|(\s*$)/g, ""); function ltrim(str){ return str.replace(/(^\s*)/g,""); function rtrim(str){ return str.replace(/(\s*$)/g,"");
function $(e){ return document.getElementById(e); String.prototype.trim = function(){ return this.replace(/(^\s+)|(\s+$)/g,""); function checkFormField(fieldObj,msgObj,re,nullMsg,errorMsg){ msgObj.innerHTML = ""; var v = fieldObj.value.replace(/(^\s+)|(\s+$)/g,""); ...
String.prototype.trim = function() return this.replace(/^\s*/, "").replace(/\s*$/, "");
String.prototype.trim = String.prototype.trim || function(){ if (!this) return this; return this.replace(/^\s+|\s+$/g, "");
String.prototype.trim = function() { return this.replace(/^\s+/, '').replace(/\s+$/, ''); };