how to remove space of string in javascript code example Example 1: js remove space from string string.split(" ").join("") Example 2: js remove spaces str = str.trim();