how to remove spaces in javascript string code example Example: delete space from string javascript var str = "470 "; str.trim();