Var trim = function (A, b) { var a = a ? a : " "; var b = b ? b : ""; if (b == "") {return ""; } var la = a.length; var lb = b.length; var s = e = false; if (B.indexOf (a) === 0 ) { s = true; } if (b.lastIndexOf (a) === lb-la) {e = true; } var r = b; if (e) {if (r.length > 0) {r = r.substring (0,lb-la); Return trim (a,r);} else { return "";} } if (s) {if (r.length > 0) { r = r.substring (la,r.length); return trim (A, r);} else { return "";} } return r;}
JS does not like the PHP trim method, its own implementation of a, convenient for personal use. If before me the cattle have been fulfilled, and the thought is consistent, please do not laugh. Coincidence, because I did not learn from anyone.
This article is from the "Rhino" blog, please make sure to keep this source http://rhino.blog.51cto.com/5504750/1761971
JS implementation similar to the PHP trim method