Thursday, August 28, 2014

trim in js

.trim() in JavaScript does just what you'd think...

var urlVariables = window.location.href.split("/");
if (urlVariables[urlVariables.length-1].trim() == "") {

 
 

Addendum 2/3/2018: .trimRight() and .trimLeft() are also a thing. There is a way to do left padding to right align things too. I'm not sure how "pad left" and "trim end" or "trim start" all work.

No comments:

Post a Comment