You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: chapters/strings/trimming-whitespace-from-a-string.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,7 @@ To trim only trailing whitespace, use the following:
37
37
Opera, Firefox and Chrome all have a native string prototype `trim` method, and the other browsers could add one as well. For this particular method, I would use the built-in method where possible, otherwise create a polyfill:
38
38
39
39
{% highlight coffeescript %}
40
-
if !String::trim? then String::trim = -> @replace /^\s+|\s+$/g, ""
40
+
unless String::trim then String::trim = -> @replace /^\s+|\s+$/g, ""
0 commit comments