Trim Your Whitespace

added by DotNetKicks
1/10/2022 7:39:31 PM

241 Views

Leading and trailing whitespace are generally invisible. Humans are bad at dealing with things they can't see. If your system accepts textual codes, or any other human-generated or human-mediated input, you should trim whitespace, whether it's leading, trailing, or inline (if not meaningful). // Trim leading and trailing whitespace $('inputCode').value = $('inputCode').value.trim(); It's downright silly...


0 comments