let username = " jshype.com " let password = " pass123 " console.log(username.trim()) // "jshype.com" console.log(password.trim()) // "pass123"
The trim() method is very helpful in the HTML forms. for example Login, SignUp forms.
In Login forms sometimes user forgot to remove the white space and start typing username and password then he/she unable to login in such cases
trim() method shines.